I have the following code using the Speech Recognition library:
var listen = new SpeechRecognitionEngine(); var reader = new Choices(File.ReadLines(@"C:\words.txt") listen.LoadGrammar(new Grammar(new GrammarBuilder(reader))); listen.SpeechRecognized += listen_SpeechRecognized; listen.SpeechRecognitionRejected += listen_SpeechRecognitionRejected; listen.SetInputToDefaultAudioDevice(); listen.RecognizeAsync(RecognizeMode.Multiple); And I have an event listener like this...
static void listen_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { var talk = new SpeechSynthesizer(); if (e.Result.Text == "Search Stock Symbol") { talk.Speak("What symbol?"); //Do I have to create another event listener? //a Listener .. symbol = a.Result.Text //talk.Speak(GetQuote(symbol)) { } Would I have to create an event listener for every portion of the "conversation"? Is there a better way if that is the case?
Example Conversation:
- Me: Search Stock Symbol
- Computer: What Symbol?
- Me: AAPL
- Computer: Apple is trading at ....