调用speechrecognizerengine来停止C#中的speak()方法 [英] Call speechrecognizerengine to stop speak() method in C#
问题描述
我想通过在c#speechsynthesizer和speechrecognition引擎中说停止来停止当前运行的线程,问题是说话会阻止系统并继续说出我的收件箱电子邮件的文本,因为电子邮件太大我想要说停止说话并继续下一个任务,但它在完成之前不会做任何其他任务,我该怎么做?
我有什么尝试过:
speakasync()无法工作我已经尝试过了
I want to stop the current running thread by saying "stop" in c# speechsynthesizer and speechrecognition engine, the problem is the speak would block the system and keep on speaking the text of my inbox email , since emails are too large I want to say stop between speaking and move on to next task but it wont do any other task before it finishes , how can i do this?
What I have tried:
speakasync() wont work I have tried it
推荐答案
我推荐创建另一个始终处于活动状态的识别器对象,它只会识别您的停止
或继续说
字。
stopRecognizer
应该停止主要的。
这是一个代码示例:
I recommend creating another recognizer object that is always active and it will only recognize yourstop
orcontinue speaking
words.
ThestopRecognizer
should then stop the main one.
Here's a code sample:
private SpeechRecognitionEngine stopListener = new SpeechRecognitionEngine(new CultureInfo("en-US"));
private SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine(new CultureInfo("en-US"));
private SpeechSynthesizer speaker = new SpeechSynthesizer();
在 stopListener
的已识别事件中,您应该创建 SpeechSynthesizer
停止发言。
In the Recognized event of stopListener
you should make the SpeechSynthesizer
stop speaking.
这篇关于调用speechrecognizerengine来停止C#中的speak()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!