我试图识别简单的英语单词,但没有识别发生。
private void Form1_Load(object sender, EventArgs e)
{
SpeechRecognitionEngine srEngine = new SpeechRecognitionEngine();
// Create a simple grammar that recognizes "twinkle", "little", "star"
Choices song_00 = new Choices();
song_00.Add(new string[] {"twinkle", "little", "star"});
// Create a GrammarBuilder object and append the choices object
GrammarBuilder gb = new GrammarBuilder();
gb.Append(song_00);
// Create the grammar instance and load it into the sppech reocognition engine.
Grammar g = new Grammar(gb);
g.Enabled = true;
srEngine.LoadGrammar(g);
srEngine.SetInputToDefaultAudioDevice();
// Register a handler for the Speechrecognized event.
srEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
srEngine.RecognizeAsync(RecognizeMode.Multiple);
}
// Create a simple handler for the SpeechRecognized event.
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("Speech recognized: " + e.Result.Text);
}
下面的一个也没有显示任何消息。
foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
MessageBox.Show(ri.Culture);
}
所以我认为失败的主要原因是语言。
有什么解决方案可以在非英语版本的 Windows 中使用英语识别吗?还是有我没有注意到的问题?
- 现在我使用的是非英文版的windows7(64位),我的麦克风连接良好。(我已经检查了控制面板。)