Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private static SpeechRecognitionEngine Rec = new SpeechRecognitionEngine(new CultureInfo("es-ES"));
  2. private static SpeechSynthesizer Synth = new SpeechSynthesizer();
  3. private static System.Timers.Timer CountDown = new System.Timers.Timer();
  4. private static System.Media.SoundPlayer Player = new System.Media.SoundPlayer(@"sound.wav");
  5. public static DBConnection Connection = new DBConnection();
  6.  
  7. public static void Start()
  8. {
  9. DBConnection connection = new DBConnection();
  10. Choices commands = new Choices();
  11. commands.Add(connection.RetrieveAllWords());
  12. GrammarBuilder gBuilder = new GrammarBuilder();
  13. gBuilder.Append(commands);
  14. Grammar grammar = new Grammar(new GrammarBuilder(gBuilder, 0, 100));
  15. CountDown.Elapsed += new ElapsedEventHandler(TimesUp);
  16. CountDown.Interval = 10000;
  17. CountDown.Enabled = true;
  18. CountDown.AutoReset = false;
  19. try{Rec.LoadGrammarAsync(grammar);}
  20. catch(FormatException e){MessageBox.Show(e.Message, e.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);}
  21. Rec.SetInputToDefaultAudioDevice();
  22. Rec.RecognizeAsync(RecognizeMode.Multiple);
  23. Rec.SpeechRecognized += Rec_SpeechRecognized;
  24. Application.Run(new ManualActivation());
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement