Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I making a Windows Form app that uses the Speech SDK (SAPI 5.1) to do some text to speech functions. Here's the code I'm using.

using SpeechLib;
public SpVoice obSpeech = new SpVoice();
obSpeech.Speak("Some really long sentence", SpeechVoiceSpeakFlags.SVSFlagsAsync);


Now when I give a really long sentence, it continues speaking till it finishes the sentence. Is there any way to stop the speech in mid-sentence? What I mean is, when I press a button (say btnStop), can I make it stop speaking?
Please help.
Posted
Updated 13-Mar-10 8:59am
v2

S.Raaj Nishanth wrote:
Now when i give a really long sentence, it continues speaking till it finishes the sentence. Is there any way to stop the speech in mid-sentence?


Yup, this should do the trick:

C#
void Button1_Click(object sender, EventArgs e)
{
    obSpeech.Speak("", SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
}
 
Share this answer
 
v2
That worked beautifully!!! Thank you very much! :) :) :-D
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900