speech recognition - No response from my C# program -
the program works using speech recognition, , based on jarvis.. want able use different languages speech recognition, such danish , english. problem don't response. cant seem figure out if response or if speech detected , read.
public partial class form1 : form { speechrecognitionengine _recognizer = new speechrecognitionengine(); speechsynthesizer dexter = new speechsynthesizer(); string qevent; string procwindow; double timer = 10; int count = 1; random rnd = new random(); public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { _recognizer.setinputtodefaultaudiodevice(); _recognizer.loadgrammar(new dictationgrammar()); _recognizer.loadgrammar(new grammar(new grammarbuilder(new choices(file.readalllines(@"c:\commands.txt"))))); _recognizer.speechrecognized += new eventhandler<speechrecognizedeventargs>(_recognizer_speechrecognized); _recognizer.recognizeasync(recognizemode.multiple); } void _recognizer_speechrecognized(object sender, speechrecognizedeventargs e) { int rannum = rnd.next(1, 10); string speech = e.result.text; switch (speech) { //greetings case "hey dexter": case "hej dexter": if (rannum < 6) { dexter.speak("hej sir"); } else if (rannum > 5) { dexter.speak("hej"); } break; case "shut down dexter": case "luk ned dexter": dexter.speak("så ses vi"); close(); break; case "dexter": if (rannum < 5) { qevent = ""; dexter.speak("ye sir"); } else if (rannum > 4) { qevent = ""; dexter.speak("ye"); } break; } } }
Comments
Post a Comment