void sre_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e) { var said = new SaidSomethingArgs(); said.Verb = Verbs.None; said.Matched = "?"; SaidSomething(new object(), said); Console.WriteLine("\nSpeech Rejected"); }
void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.WriteLine("\nSpeech Recognized: \t{0}", e.Result.Text); SaidSomethingArgs said = new SaidSomethingArgs(); said.text = ""; if (e.Result.Text.CompareTo("kinect") == 0) kinectSpoken = true; else if (!rerackSpoken && e.Result.Text.CompareTo("rerack") == 0) rerackSpoken = true; if (kinectSpoken) said.text = "kinect"; if (rerackSpoken) said.text += " rerack "; if (kinectSpoken && rerackSpoken && rerackOptions.ContainsKey(e.Result.Text)) { said.text += e.Result.Text; kinectSpoken = false; rerackSpoken = false; } SaidSomething(new object(), said); }
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.Write("\rSpeech Recognized: \t{0}", e.Result.Text); if (SaidSomething == null) return; var said = new SaidSomethingArgs(); said.RGBColor = Color.FromRgb(0, 0, 0); said.Shape = 0; said.Verb = 0; said.Phrase = e.Result.Text; // First check for color, in case both color _and_ shape were both spoken bool foundColor = false; foreach (var phrase in ColorPhrases) if (e.Result.Text.Contains(phrase.Key) && (phrase.Value.verb == Verbs.Colorize)) { said.RGBColor = phrase.Value.color; said.Matched = phrase.Key; foundColor = true; break; } // Look for a match in the order of the lists below, first match wins. List<Dictionary<string, WhatSaid>> allDicts = new List<Dictionary<string, WhatSaid>>() { GameplayPhrases, ShapePhrases, ColorPhrases, SinglePhrases }; bool found = false; for (int i = 0; i < allDicts.Count && !found; ++i) { foreach (var phrase in allDicts[i]) { if (e.Result.Text.Contains(phrase.Key)) { said.Verb = phrase.Value.verb; said.Shape = phrase.Value.shape; if ((said.Verb == Verbs.DoShapes) && (foundColor)) { said.Verb = Verbs.ShapesAndColors; said.Matched += " " + phrase.Key; } else { said.Matched = phrase.Key; said.RGBColor = phrase.Value.color; } found = true; break; } } } if (!found) return; if (paused) // Only accept restart or reset { if ((said.Verb != Verbs.Resume) && (said.Verb != Verbs.Reset)) return; paused = false; } else { if (said.Verb == Verbs.Resume) return; } if (said.Verb == Verbs.Pause) paused = true; SaidSomething(new object(), said); }
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.Write("\rSpeech Recognized: \t{0}", e.Result.Text); if (SaidSomething == null) { return; } var said = new SaidSomethingArgs(); said.RGBColor = Color.FromRgb(0, 0, 0); said.Shape = 0; said.Verb = 0; said.Phrase = e.Result.Text; // First check for color, in case both color _and_ shape were both spoken bool foundColor = false; foreach (var phrase in ColorPhrases) { if (e.Result.Text.Contains(phrase.Key) && (phrase.Value.verb == Verbs.Colorize)) { said.RGBColor = phrase.Value.color; said.Matched = phrase.Key; foundColor = true; break; } } // Look for a match in the order of the lists below, first match wins. List <Dictionary <string, WhatSaid> > allDicts = new List <Dictionary <string, WhatSaid> >() { GameplayPhrases, ShapePhrases, ColorPhrases, SinglePhrases }; bool found = false; for (int i = 0; i < allDicts.Count && !found; ++i) { foreach (var phrase in allDicts[i]) { if (e.Result.Text.Contains(phrase.Key)) { said.Verb = phrase.Value.verb; said.Shape = phrase.Value.shape; if ((said.Verb == Verbs.DoShapes) && (foundColor)) { said.Verb = Verbs.ShapesAndColors; said.Matched += " " + phrase.Key; } else { said.Matched = phrase.Key; said.RGBColor = phrase.Value.color; } found = true; break; } } } if (!found) { return; } if (paused) // Only accept restart or reset { if ((said.Verb != Verbs.Resume) && (said.Verb != Verbs.Reset)) { return; } paused = false; } else { if (said.Verb == Verbs.Resume) { return; } } if (said.Verb == Verbs.Pause) { paused = true; } SaidSomething(new object(), said); }
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.Write("\rSpeech Recognized: \t{0}", e.Result.Text); if (SaidSomething == null) return; var said = new SaidSomethingArgs(); said.Instruments = 0; // First check for color, in case both color _and_ shape were both spoken foreach (var phrase in InstrumentPhrases) if (e.Result.Text.Contains(phrase.Key)) { said.Instruments = phrase.Value.instruments; said.Matched = phrase.Key; break; } SaidSomething(new object(), said); }
void sre_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e) { var said = new SaidSomethingArgs(); said.Instruments = Instruments.Piano; said.Matched = "?"; SaidSomething(new object(), said); Console.WriteLine("\nSpeech Rejected - Default Piano Selected"); }
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.WriteLine("Speech Recognized: \t{0}", e.Result.Text); //if (SaidSomething == null) // return; var said = new SaidSomethingArgs(); said.Verb = 0; said.Angle = 0; said.Phrase = e.Result.Text; // Look for a match in the order of the lists below, first match wins. List<Dictionary<string, WhatSaid>> allDicts = new List<Dictionary<string, WhatSaid>>() { SinglePhrases, GameplayPhrases, NumberPhrases }; bool found = false; for (int i = 0; i < allDicts.Count && !found; ++i) { //Console.WriteLine("im in dict " + i); foreach (var phrase in allDicts[i]) { if (e.Result.Text.Contains(phrase.Key)) { said.Verb = phrase.Value.verb; Console.WriteLine("Found a verb: " + said.Verb); { said.Matched = phrase.Key; } if (said.Verb == Verbs.Number) { Console.WriteLine("I really should be " + phrase.Value.angle); said.Angle = phrase.Value.angle; Console.WriteLine("Im a number " + said.Angle); } found = true; break; } } } if (!found) { Console.WriteLine("Nothing in the Dictionary"); return; } Console.WriteLine("My verb is " + said.Verb); if (said.Verb == Verbs.Pause) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Pause; else if (said.Verb == Verbs.Reset) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Reset; else if (said.Verb == Verbs.Resume) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Resume; else if (said.Verb == Verbs.Ready) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Ready; else if (said.Verb == Verbs.Angle) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Angle; else if (said.Verb == Verbs.Number) { thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Number; thisGameIsAwesome.screenManager.input.myAngle = said.Angle; } else if (said.Verb == Verbs.Fire) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Fire; else if (said.Verb == Verbs.Up) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Up; else if (said.Verb == Verbs.Down) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Down; else if (said.Verb == Verbs.Movement) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Movement; else if (said.Verb == Verbs.Enter) thisGameIsAwesome.screenManager.input.currentVoiceCommand = InputState.voiceCommandStates.Enter; //SaidSomething(new object(), said); }