奇怪的是我的程序只能识别中文。顺便说一句,我在中国。
即使我安装了visual c# 2010的英文版,它仍然只能识别中文。
如何更改语言设置?
private void InitializeRecognizerSynthesizer()
{
var selectedRecognizer = (from e in SpeechRecognitionEngine.InstalledRecognizers()
where e.Culture.Equals(Thread.CurrentThread.CurrentCulture)
select e).FirstOrDefault();
recognizer = new SpeechRecognitionEngine(selectedRecognizer);
recognizer.AudioStateChanged+=new EventHandler<AudioStateChangedEventArgs>(recognizer_AudioStateChanged);
recognizer.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(recognizer_SpeechHypothesized);
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
synthesizer = new SpeechSynthesizer();
}
然后我改变 var selectedRecognizer = (from e in SpeechRecognitionEngine.InstalledRecognizers() where e.Culture.Equals(Thread.CurrentThread.CurrentCulture) select e).FirstOrDefault();
到 e.Culture.Equals("en");
但它似乎是识别器的一个例外 = new SpeechRecognitionEngine(selectedRecognizer); 说检查以确定对象是否为空。
我使用麦克风作为控制面板中的默认音频输入设备。
我刚才在http://msdn.microsoft.com/en-us/library/ms554259.aspx中尝试过这个最简单的代码 。还会出现异常警告句子中没有此类文化标识符: SpeechRecognitionEngine Recognizer = new SpeechRecognitionEngine( new System.Globalization.CultureInfo("en-US")))