How to temporarily suspend SpVoice in WPF?

I want to make text to speech with many voices in many languages.

I tried SpeechSynthesizer (Ref: System.Speech), but it only allows 2 English voices. After installing 6 English votes from the Microsoft website, I still cannot get any other votes.

I changed to SpVoice (Link: Microsoft Speech Object Library). SpVoice can recognize the 6 votes that I just installed. The problem is that when I call spVoice.Pause() , it always delays 0.5 seconds before it stops talking completely. I also tried installing AlertBoundary for SpVoice, but that didn't help.

SpeechSynthesizer can pause with SpeakAsyncCancelAll , but only works with default voices.

+5
source share
1 answer

Basically, the Pause method pauses the voice at the nearest warning border and closes the output device, allowing it to use other voices.

spVoice.Speak() can be called synchronously or asynchronously. When called synchronously, the method does not return until the text is spoken; when called asynchronously, it returns immediately, and the voice speaks as a background process.

Hope you call spVoice.Speak() synchronously. That is why you get this problem. Therefore, instead of using synchronous use the asynchronous method, your problem should be solved. Then spVoice.Pause() will stop immediately.

 SpVoice spVoice = new SpVoice (); spVoice.Speak ("Testing spVoice",SpeechVoiceSpeakFlags.SVSFlagsAsync); //...... spVoice.Pause(); 
0
source

All Articles