Running a basic speech recognition program with windows 7 in c# VS 2010, it compiles, but it does not run -
i tried writing basic speech recognition using c# (winformsapp) in vs 2010 on windows 7 dell computer. able make work using basic examples microsoft (http://msdn.microsoft.com/en-us/magazine/cc163663.aspx#s5) , forums one. however, needed change computers , trying replicate on lenovo computer same specs. not work, in fact, speech recognition keeps interfering program running , when changed speechrecognitionengine
still doesn't run. able compile no error, not see result, is, messagebox showing e.result.text
.
my code below:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.speech.recognition; using system.threading; namespace speechrecogtest { public partial class form1 : form { speechrecognitionengine sr = new speechrecognitionengine(); public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { //create grammar choices words = new choices(); words.add("hi"); words.add("no"); words.add("yes"); grammar wordslist = new grammar(new grammarbuilder(words)); wordslist.speechrecognized += new eventhandler<speechrecognizedeventargs>(rec_speechrecognized); sr.loadgrammar(wordslist); } void rec_speechrecognized(object sender, recognitioneventargs e) { messagebox.show(e.result.text); } } }
i appreciate help. pretty sure have installed sdks, including sapi 5.1, windows sdk v7.0 , v7.1, have included speech libraries both com , net, , built synthesizer works.
you loaded grammar, did ever call sr.recognizeasync(); ?
you have call either recognize() synchronous recognition or recognizeasync() perform recognition. have done neither.
assuming capturing audio soundcard, after grammar loaded, try:
sr.setinputtodefaultaudiodevice(); sr.recognizeasync();
to started .net speech, there article published few years ago @ http://msdn.microsoft.com/en-us/magazine/cc163663.aspx. best introductory article i’ve found far. little out of date, helfpul. (the appendresultkeyvalue method dropped after beta.)
Comments
Post a Comment