Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught DOMException: Failed to set the 'duration' property on 'MediaSource' #565

Open
waymorphood opened this issue Sep 2, 2022 · 2 comments
Assignees

Comments

@waymorphood
Copy link

I am using SpeechSynthesizer for TTS

Intermittently the voice does not emit audio and I see this in the console.log:

SpeakerAudioDestination.js?38ca:132 Uncaught DOMException: Failed to set the 'duration' property on 'MediaSource': The 'updating' attribute is true on one or more of this MediaSource's SourceBuffers.
at privMediaSource.onsourceopen (webpack-internal:///./node_modules/microsoft-cognitiveservices-speech-sdk/distrib/es2015/src/sdk/Audio/SpeakerAudioDestination.js:138:51)

Once this happens, every subsequent call to synthesize (speatkTextAsync) generates same error.

@glharper glharper self-assigned this Sep 5, 2022
@waymorphood
Copy link
Author

I've narrowed this down. Our application uses SpeechToText (startContinuousRecognitionAsync) and then performs Text To Speech (speakTextAsync), both using cognitiveservices SDK. The above error only happens when we use STT and TTS

@glharper glharper assigned yulin-li and unassigned glharper Sep 13, 2022
@KenjiPcx
Copy link

KenjiPcx commented Apr 8, 2023

I was experiencing the same thing, I was adding tts to a Next.js app and this happened because my AudioConfig initialization was outside my "synthesizeSpeech" function/component. It works fine when I moved all the logic into the function.

If your situation is the same as mine, try moving all your tts logic into one function like this

const synthesize = () => {
    if (!inputBox.current) return;

    const audioConfig = AudioConfig.fromDefaultSpeakerOutput();
    const speechSynthesizer = new SpeechSynthesizer(speechConfig, audioConfig);
    speechSynthesizer.speakTextAsync(
      inputBox.current.value,          // the value from my input box
      (result) => {
        if (result) {
          speechSynthesizer.close();
          return result.audioData;
        }
      },
      (error) => {
        console.log(error);
        speechSynthesizer.close();
      }
    );
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants