c# - How to get this code to work using the speech recognition engine instead of the default windows popup recognizer -


i still working on speech pronunciation test. have code, need use speechrecognitionengine instead of system popup recognizer. bit of working code in vb, though prefer work in c#, has been difficult settle whatever code or programming language can get. code totally functional, , can tested pasting empty vb projects, , including import system.speech.recognition. can show me how make code use speechengine .

i can discuss setting default audio input , getting rid of recognizer start code, of course must removed. but, keep things simple, have left code live testing. thanks

imports system.speech.recognition  imports system.threading  imports system.globalization  public class form1      ' recogniser & grammar     dim recog new speechrecognizer     dim gram grammar     ' events     public event speechrecognized _         eventhandler(of speechrecognizedeventargs)     public event speechrecognitionrejected _         eventhandler(of speechrecognitionrejectedeventargs)     ' word list     dim wordlist string() = new string() {"yes", "no", "maybe"}     ' word recognised event     public sub recevent(byval sender system.object,             byval e recognitioneventargs)         labelyes.forecolor = color.lightgray         labelno.forecolor = color.lightgray         labelmaybe.forecolor = color.lightgray         if (e.result.text = "yes")             labelyes.forecolor = color.green         elseif (e.result.text = "no")             labelno.forecolor = color.green         elseif (e.result.text = "maybe")             labelmaybe.forecolor = color.green         end if     end sub     ' recognition failed event     public sub recfailevent(byval sender system.object,             byval e recognitioneventargs)         labelyes.forecolor = color.lightgray         labelno.forecolor = color.lightgray         labelmaybe.forecolor = color.lightgray     end sub     ' form initialisation     private sub form1_load(byval sender system.object,             byval e system.eventargs) handles mybase.load         ' need these british english rather default         thread.currentthread.currentculture = new cultureinfo("en-gb")         thread.currentthread.currentuiculture = new cultureinfo("en-gb")         ' convert word list grammar         dim words new choices(wordlist)         gram = new grammar(new grammarbuilder(words))         recog.loadgrammar(gram)         ' add handlers recognition events         addhandler recog.speechrecognized, addressof me.recevent         addhandler recog.speechrecognitionrejected, addressof me.recfailevent         ' enable recogniser         recog.enabled = true     end sub end class 


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -