Gwowen
Gwowen

Reputation: 178

Microsoft Cognitive TTS onAudioEnd event not working

I am using the JavaScript version of Microsoft Cognitive Services Speech SDK from https://github.com/Azure-Samples/cognitive-services-speech-sdk.

About the SpeechSynthesizer, I include SpeakerAudioDestination to it. I want to do something when the audio playback is done so I add onAudioEnd event, but it is never fired. Is the code below correct?

    player = new SpeechSDK.SpeakerAudioDestination();
    player.onAudioEnd = function (s) {
      console.log("onAudioEnd", s);
    };
    synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, 
      SpeechSDK.AudioConfig.fromSpeakerOutput(player));

Any help is appreciated!

Upvotes: 3

Views: 1270

Answers (1)

Gwowen
Gwowen

Reputation: 178

Inside the synthesizer.speakTextAsync() callback, synthesizer.close() needs to called for player.onAudioEnd event to be fired.

Upvotes: 5

Related Questions