I'm working with Speech Platform Run time of Microsoft and i'm using the SpVoice
interface to make the run time speak the sentences i want.
To Stop the speech mid sentence i created my function like this
public void StopSpeak()
{
try
{
Speaker.Speak("", SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
}
catch (COMException ex)
{
}
}
But when i run this while the Speech Platform is speaking i get this com error:
Exception from HRESULT: 0x80045006
I looked it up by Microsoft and it means that the wave device is busy, i now realize that i get this error every time the Speech Platform is busy speaking a sentence.
Is there a other way to stop the speech mid sentence using SpVoice or any other interface or class that comes with the Speech Platform Runtime ?
Thanks.
To stop the Speech without having to deal with the exception, use the Skip
method on SpVoice
. Documentation here.
This should work, as it will skip int.MaxValue
sentences:
public void StopSpeak()
{
Speaker.Skip("Sentence", int.MaxValue);
}
First of All you have to set SpeechVoiceSpeakFlags to Asyncronous one. That way you will be able to cut speaking in periods or punctuation. Via Pause Method.
Speaker.Speak("Long Text Here", SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync);
Speaker.Pause();
But it will again finish the sentence that it began reading then it will stop in punctuations if there is any.So There is no cutting the sequence.
a harsh way to do is set it null ; Speaker = null; aftre resume you have to set it again ,with where it stopped and where to continue.
User contributions licensed under CC BY-SA 3.0