本文介绍了SpeechRecognizeEngine不触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用了Mycrosoft语音识别引擎,该引擎工作正常,但未引发SpeechRecognized和SpeechHypothesized事件.
代码在下面给出
Hi,
I have used Mycrosoft Speech Recognize Engine, that is working fine, but not firing SpeechRecognized and SpeechHypothesized event.
Code is given below
SpeechRecognitionEngine _sre = new SpeechRecognitionEngine();
_sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
_sre.SpeechHypothesized+=new EventHandler<SpeechHypothesizedEventArgs>(_sre_SpeechHypothesized);
_sre.SetInputToDefaultAudioDevice();
_sre.RecognizeAsync(RecognizeMode.Multiple);
请任何人知道解决方案,请堆我.
Kailas
Please anyone know the solution please heap me.
Kailas
推荐答案
//create an instance
SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
// Create and load a dictation grammar.
recognitionEngine.LoadGrammar(new DictationGrammar());
// Add a handler for the speech recognized event.
recognitionEngine.SpeechRecognized += new EventHandler<speechrecognizedeventargs>(recognitionEngine_SpeechRecognized);
// Configure input to the speech recognizer.
recognitionEngine.SetInputToDefaultAudioDevice();
void recognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//recognize your speech here
}
这篇关于SpeechRecognizeEngine不触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!