たとえば、画面の中央でマウスをクリックするコマンド「center」が必要だとしましょう。些細な例ですが、文法的な側面にもっと興味があります。
"center" だけを一致させたい場合はどうすればよいですか?
一時停止して「中央」と言ってから一時停止すると一致します。
でも「私は部屋の真ん中にいる」と言ったら一致しません。
次のコードは、フレーズのどの部分で話されていても、「center」という単語に一致するようです。
Choices center = new Choices( new string[] { "center" } );
SemanticResultKey centerKeys = new SemanticResultKey( "center", center );
GrammarBuilder centerGrammarBuilder = new GrammarBuilder();
centerGrammarBuilder.Append( centerKeys );
speechRecognitionEngine.UnloadAllGrammars();
speechRecognitionEngine.LoadGrammar(new Grammar(centerGrammarBuilder));