c# - 'SAPI does not implement phonetic alphabet selection' exception -
whenever attempt code speech recognition program in laptop,i same messages mentioned below..i can compile code , windows form application working..but problem is, program not detect voice..and program wont work..
i sure codes works fine take codes youtube videos : https://www.youtube.com/watch?v=kr0-uyugyga , many more.. using .net framework 4 client profile projects.. make reference "system.speech"...what might problem ?
debug messages :
speaker.vshost.exe information: 0 : sapi not implement phonetic alphabet selection. first chance exception of type 'system.runtime.interopservices.comexception' occurred in system.speech.dll first chance exception of type 'system.invalidoperationexception' occurred in system.speech.dll first chance exception of type 'system.invalidoperationexception' occurred in system.speech.dll first chance exception of type 'system.invalidoperationexception' occurred in system.speech.dll
sample code tried :
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.synthesis; using system.speech.recognition; using system.threading; using system.threading.tasks; namespace speaker { public partial class form1 : form { public form1() { initializecomponent(); } speechsynthesizer ssynth = new speechsynthesizer(); promptbuilder pbuilder = new promptbuilder(); speechrecognitionengine srecognize = new speechrecognitionengine(); private void form1_load(object sender, eventargs e) { } private void button1_click(object sender, eventargs e) { pbuilder.clearcontent(); pbuilder.appendtext(textbox1.text); ssynth.speak(pbuilder); } private void button2_click(object sender, eventargs e) { button2.enabled = false; button2.enabled = true; choices slist = new choices(); slist.add(new string[]{"hello","test","it works","how","are","you","today"}); grammar gr = new grammar(new grammarbuilder(slist)); try { srecognize.requestrecognizerupdate(); srecognize.loadgrammar(gr); srecognize.speechrecognized += new eventhandler<speechrecognizedeventargs>(srecognize_speechrecognized); srecognize.setinputtodefaultaudiodevice(); srecognize.recognizeasync(recognizemode.multiple); } catch { return; } } void srecognize_speechrecognized(object sender, speechrecognizedeventargs e) { //if (e.result.confidence >= 0.3) messagebox.show("speech is:" + e.result.text.tostring()); } } }
you need
gram.culture = new system.globalization.cultureinfo("en-gb")
for more details see
http://www.vbforums.com/showthread.php?751297-resolved-(vs2102)-speech-recognition-suddenly-stopped
in which part of the code that i want to embed this line?
ReplyDelete