Search code examples
reactjstext-to-speechazure-cognitive-services

How to detect end of speech in microsoft-speech tts sdk


I am using microsoft-cognitiveservices-speech-sdk in react for text to speech. I want to run a specific function when the text is finished being spoken. However I am unable to find a way to detect the end of the speech using the sdk. I just need a way to detect when the audio is finishd playing by the sdk so I can run my function


Solution

  • The SDK has a onAudioEnd event, see this sample.

    Also, remember to close the synthesizer, see this question for details.