c++windowstext-to-speechspeechsapi

SAPI - How to stop all asynchronous speech tasks?


I'm using the Microsoft's Speech Application Programming Interface (SAPI) to enable speech in my app. However, when I try to stop asynchronous speech tasks, they stop, but after a second.

In .NET framework, I tried to stop all asynchronous speech tasks, and they stop immediately when I call the SpeechSynthesizer.SpeakAsyncCancelAll. However, when I try to cancel speech in SAPI (C++), speech stopped but after a second (or more). I call ISpVoice::Speak with the SVSFlagsAsync, and of course the SVSFPurgeBeforeSpeak from the SpeechVoiceSpeakFlags enumeration. I tried to call ISpVoice::Pause, then trying to speak again, but it still speaks after a second. I tried using ISpVoice::Skip also, but it didn't work. I tried ISpVoice::SetPriority to Alert, but it didn't stop the speech. I wonder if there is some W3C SSML tag to stop speech that I will send to ISpVoice::Speak as Speech Synthesis Markup language (SSML)? Or if there is some way to stop asynchronous speech tasks immediately?


Solution

  • Maybe you could construct two ISpAudio interfaces, then switching between them whenever you need to stop speech.