Advertisement
Guest User

Untitled

a guest
Dec 8th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Speech.Recognition;
  6.  
  7. namespace Test
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // Create an in-process speech recognizer for the en-US locale.
  14. SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("es-ES"));
  15.  
  16. // Create and load a dictation grammar.
  17. recognizer.LoadGrammar(new DictationGrammar());
  18.  
  19. // Add a handler for the speech recognized event.
  20. recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
  21.  
  22. // Configure input to the speech recognizer.
  23. recognizer.SetInputToDefaultAudioDevice();
  24.  
  25. // Start asynchronous, continuous speech recognition.
  26. recognizer.RecognizeAsync(RecognizeMode.Multiple);
  27.  
  28. // Keep the console window open.
  29. Console.ReadLine();
  30. }
  31.  
  32. // Handle the SpeechRecognized event.
  33. static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
  34. {
  35. Console.WriteLine("Recognized text: " + e.Result.Text);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement