How to recognize a speech recognizer to start recognition?

I am working on a C # application that uses the SAPI COM component. In the following snippe code, how can I tell the recognizer to start recognizing based on the grammar and 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; 
+4
source share
1 answer

You are almost there.

 sre.SetRecoState(SPRECOSTATE.SPRST_ACTIVE); 

gotta do the trick.

+1
source

Source: https://habr.com/ru/post/1342569/


All Articles