HI ive got the following questio, i'm trying to program an simple calculator based on SpeechRecognizion . I can let is speak but how can i store the user input in a variable ?
here is my code so far
- using System;
- using System.IO;
- using System.Speech.Recognition;
- using System.Speech.Synthesis;
-
- namespace calculator
- {
- class Program
- {
- public static SpeechSynthesizer S = new SpeechSynthesizer();
- public static SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
-
- static void Main(string[] args)
- {
- S.SelectVoiceByHints(VoiceGender.Neutral);
- S.Speak("What calculation should i do for you");
-
- var calculationslist = new Choices();
- calculationslist.Add(File.ReadAllLines(@"C:\Program Files\DK's Soft\JARVIS system Commands\calculation commands\calculationcommands.txt"));
-
- var gr = new Grammar(new GrammarBuilder(calculationslist));
-
- try
- {
- rec.RequestRecognizerUpdate();
- rec.LoadGrammar(gr);
- rec.SetInputToDefaultAudioDevice();
- rec.RecognizeAsync(RecognizeMode.Multiple);
-
- var userinput = ???
-
- }
- catch (Exception)
- {
- return;
- }
- }
-
- }
- }