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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With