This is a new tutorial about C# and Speech.Recognition feature.
First, I create a console C# project and I add Speech.Recognition reference to project, see my old tutorial.
After these steps the default source code from documentation works well:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | using System; using System.Speech.Recognition; namespace Recognition_001 { class Program { static void Main(string[] args) { // Create an in-process speech recognizer for the en-US locale. using ( SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine( new System.Globalization.CultureInfo("en-US"))) { // Create and load a dictation grammar. recognizer.LoadGrammar(new DictationGrammar()); // Add a handler for the speech recognized event. recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized); // Configure input to the speech recognizer. recognizer.SetInputToDefaultAudioDevice(); // Start asynchronous, continuous speech recognition. recognizer.RecognizeAsync(RecognizeMode.Multiple); // Keep the console window open. while (true) { Console.ReadLine(); } } } // Handle the SpeechRecognized event. static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { Console.WriteLine("Recognized text: " + e.Result.Text); } } } |