I'm working with Microsoft.Speech.Recognition
and need to use quite large grammars for a recognition task. So I create and later modify a grammar as a SrgsDocument
and then construct a Grammar
object from that. At that point, I load the grammar into the engine to prepare for recognition using the SpeechRecognitionEngine.LoadGrammar
method.
In other words I have something like:
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
SrgsDocument gramDoc = new SrgsDocument();
//...modify the SrgsDocument (add rules, etc.)
Grammar gram = new Grammar(gramDoc);
sre.LoadGrammar(gram);
And at this point, loading the grammar, after a few minutes I sometimes (not always, and not really as a function of grammar size) get the error "A task could not complete because the SR engine had timed out."
If I catch the exception and try to load the same grammar into the same engine again, sometimes it loads successfully (though very slowly), and sometimes it gives the same error again.
What's causing this? Why would it sometimes time out and sometimes work with the same grammar/engine?
And is there something I can do to make the grammar load faster, period?
Any ideas would be really appreciated.