我正在使用 SAPI 创建语音识别应用程序。我需要能够为我使用的不同语法赋予不同的优先级。(听写语法和我定义的其他语法)我需要识别器在我定义的语法中进行搜索,并且仅当语音输入与我定义的语法中的任何单词都不匹配时才查看听写语法。现在我有这样的代码:
Grammar myGram;
Choices myEditor = new Choices();
myEditor.Add("public");
//adding other choices
myGram = new Grammar(new GrammarBuilder(myEditor));
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
recognizer.LoadGrammar(myGram);
Grammar dictation = new DictationGrammar();
dictation.Name = "Dictation Grammar";
recognizer.LoadGrammar(dictation);
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(
SpeechRecognizedHandler);
recognizer.SetInputToDefaultAudioDevice();
recognizer.RecognizeAsync(RecognizeMode.Multiple);
请给我任何关于如何将 myGram 优先于听写语法的想法。:)