我在Visual Studio中創建應用程序,使用語音識別進行應用程序控制。最好的方法,如何分配語音命令的事件/方法在C#
我想問你如何將語音命令分配給方法的最佳方法。使用語法生成器和選擇
I'm:
//Create Grammar Builder with Choices
GrammarBuilder slovnik = new GrammarBuilder();
slovnik.Append(new Choices("stop", "go"));
而且如果我倒是喜歡一個字從選擇到(語音命令)來分配方法(例如 - 顯示消息框) - 在事件處理程序I'm如果使用命令:
void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "stop")
{
MessageBox.Show("Some message, that the voice command works");
}
}
我的問題是 - 是如果條款如何從語法加盟詞/短語方法/事件或者有沒有更好的(清潔劑)解決方案如何最好的辦法去做?我使用C#和System.Speech.Recognition.SpeechRecognitionEngine。
非常感謝!