For example, lets say I want a command "center" that clicks the mouse in the center of the screen. Trivial example, but I'm more interested in the grammar aspects of it.
What if I only want to match "center"?
So if I pause, say "center", and then pause it is a match.
But if I say "I am in the center of the room" I do not get a match.
The following code seems to match the word "center" no matter what part of a phrase it is spoken in:
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));
The speech engines usually do a decent job making sure they don't recognize an in-grammar word in the middle of a sentence. But not always, if you have found one of those edge cases where the engine recognizes terms mid sentence I can recommend two things to help.