日期:2014-05-16 浏览次数:21161 次
public SpeechRecognitionEngine recognizer = null;
string[] order = { "暂停", "播放", "停止", "静音", "退出", "下一首", "上一首" };
GrammarBuilder grammarBuilder = new GrammarBuilder();
grammarBuilder.Append(new Choices(order));
Grammar customGrammar = new Grammar(grammarBuilder);
recognizer.UnloadAllGrammars();
recognizer.LoadGrammar(customGrammar);
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
private void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//识别结果
this.txt.Text = e.Result.Text;
}