You are loading the Grammar asynchronously, so it might happen that it isn't fully loaded yet when you start recognizing.
There are two options to avoid that:
- Load the grammar synchronously, using
LoadGrammar
instead of LoadGrammarAsync
. - If you load it async, only start the recognizer once the loading is complete. Add a
LoadGrammarCompleted
event handler which starts the recognizer:
recEngine.LoadGrammarCompleted += delegate(EventHandler<LoadGrammarCompletedEventArgs> e)
{
recEngine.SetInputToDefaultAudioDevice();
recEngine.RecognizeAsync(RecognizeMode.Multiple);
};
recEngine.LoadGrammarAsync(grammar);