Reputation: 404
I want to do 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 voices from Microsoft site, I still cannot get any other voices.
I changed to SpVoice
(Ref: Microsoft Speech Object Library). SpVoice can recognize 6 voices I just installed. The problem is when I call spVoice.Pause()
, it always delay 0.5 second before it stops speaking completely. I also tried to set AlertBoundary
for SpVoice but it didn't help.
SpeechSynthesizer can pause right away with SpeakAsyncCancelAll
but only works with default voices.
Upvotes: 5
Views: 498
Reputation: 9439
Basically,the Pause
method pauses the voice at the nearest alert boundary and closes the output device, allowing it to be used by other voices.
spVoice.Speak()
method can be called synchronously or asynchronously. When called synchronously, the method does not return until the text has been spoken; when called asynchronously, it returns immediately, and the voice speaks as a background process.
I hope you are calling spVoice.Speak()
synchronously. Thats why you are getting this issue. So use asynchronous method instead of synchronous,your problem should be solved. Then spVoice.Pause()
will pause immediately.
SpVoice spVoice = new SpVoice ();
spVoice.Speak ("Testing spVoice",SpeechVoiceSpeakFlags.SVSFlagsAsync);
//......
spVoice.Pause();
Upvotes: 0