Cassie Mod

Cassie Mod

  • NA
  • 488
  • 70.1k

how to store using input with System.Speech ??

Mar 10 2017 3:37 PM

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
 
  1. using System;  
  2. using System.IO;  
  3. using System.Speech.Recognition;  
  4. using System.Speech.Synthesis;  
  5.   
  6. namespace calculator  
  7. {  
  8.     class Program  
  9.     {  
  10.         public static SpeechSynthesizer S = new SpeechSynthesizer();  
  11.         public static SpeechRecognitionEngine rec = new SpeechRecognitionEngine();  
  12.   
  13.         static void Main(string[] args)  
  14.         {  
  15.             S.SelectVoiceByHints(VoiceGender.Neutral);  
  16.             S.Speak("What calculation should i do for you");  
  17.   
  18.             var calculationslist = new Choices();  
  19.             calculationslist.Add(File.ReadAllLines(@"C:\Program Files\DK's Soft\JARVIS system Commands\calculation commands\calculationcommands.txt"));  
  20.   
  21.             var gr = new Grammar(new GrammarBuilder(calculationslist));  
  22.   
  23.             try  
  24.             {  
  25.                 rec.RequestRecognizerUpdate();  
  26.                 rec.LoadGrammar(gr);  
  27.                 rec.SetInputToDefaultAudioDevice();  
  28.                 rec.RecognizeAsync(RecognizeMode.Multiple);  
  29.   
  30.                 var userinput = ???  
  31.   
  32.             }  
  33.             catch (Exception)  
  34.             {  
  35.                 return;  
  36.             }  
  37.         }  
  38.   
  39.     }  
  40. }  
 

Answers (1)