Reputation: 149
I am working on a c# application that uses the SAPI COM component. In the following code snippe, how can I tell the recognizer to start recognition based on the grammar and the wav file? Thanks.
ISpRecognizer sre = new SpInprocRecognizerClass();
ISpRecoContext context = null;
sre.CreateRecoContext(out context);
ISpRecoGrammar grammar = null;
context.CreateGrammar(1, out grammar);
grammar.LoadCmdFromFile(@"c:\grammar", SPLOADOPTIONS.SPLO_STATIC);
grammar.SetGrammarState(SPGRAMMARSTATE.SPGS_ENABLED);
SpFileStreamClass fs = new SpFileStreamClass();
fs.Open(@"c:\1.wav", SpeechStreamFileMode.SSFMOpenForRead, false);
((SpInprocRecognizerClass)sre).AudioInputStream = fs;
Upvotes: 4
Views: 568
Reputation: 13932
You're almost there.
sre.SetRecoState(SPRECOSTATE.SPRST_ACTIVE);
should do the trick.
Upvotes: 1