Open Roopesh-Bharatwaj-K-R opened 5 days ago
Hey, @Roopesh-Bharatwaj-K-R . Hope this helps
I have used the microsoft-cognitiveservices-speech-sdk for viseme so I have used ref in ReactJS for the synthesizer.
import * as sdk from "microsoft-cognitiveservices-speech-sdk"
const synthesizeSpeech = text => { return new Promise((resolve, reject) => { if (!speechSynthesizerRef.current) { const speechConfig = sdk.SpeechConfig.fromSubscription( import.meta.env.VITE_SPEECH_KEY, import.meta.env.VITE_SPEECH_REGION ) speechSynthesizerRef.current = new sdk.SpeechSynthesizer(speechConfig) let speechStarted = false ..... }
And to stop the speech, I did this const stopSpeech = () => { try { setImageIndex(0) setIsAudioPlaying(false) if (speechSynthesizerRef.current) { const audio = speechSynthesizerRef.current.privAdapter?.privSessionAudioDestination?.privDestination ?.privAudio if (audio) { audio.pause() audio.currentTime = 0 speechSynthesizerRef.current.close() speechSynthesizerRef.current = null } } } catch (e) { console.error("Error in stopSpeech:", e) } }
This helped in stopping the speech as well as resetting the synthesis, so if you play it again, the audio starts too.
Hi Azure,
I have created a React app that utilises the Azure Speech (TTS) solution and, it's working fine.
I have used the Javascript and followed the JS Speech Synthesis documentation from Azure:
[https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-speech-synthesis?pivots=programming-language-javascript&tabs=browserjs%2Cterminal#synthesize-speech-to-a-file]
But the issue popped when we try to stop the speaking, we could not stop the speech from the azure, and when i checked the code, there was no methods which calls direct stop, instead i could see, Close(), Cancel().
Which was not working fine and i did check the couple of issues related to the same. [SpeechSynthesizer.StopSpeakingAsync()] which was also not working fine.
I tried other approaches to do refreshing of the audio, and synthesis to Null. But it was not working fine
kindly suggest to me the best way how stop the audio from the azure TTS. Kindly share some of the Notebooks and code examples to resolve the stopping effectively.
Thanks in Advance for your kind suggestions.
Best, Roopesh