Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm making a program that teaches English (on Windows 10) and it has the user reading some terms, I made it with the Windows 7 engine:

C#
using System.Speech.Recognition;


which is extremely buggy. It also opens a gadget in Windows. Should I instead make it with:

C#
Windows.Media.SpeechRecognition


If so, how?

What I have tried:

C#
// Create an in-process speech recognizer for the en-US locale.  
        SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));

 try
            {
                // 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);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //Console.WriteLine("Recognized text: " + e.Result.Text);
            if (e.Result.Text == term)
            {
                BackColor = Color.Green;
                Program.speak("Correct.");
            }
            else
            {
                //Program.speak("Wrong");
            }
        }
Posted
Updated 21-Jan-22 9:26am
v4
Comments
BillWoodruff 22-Jan-22 7:45am    
What happens ... or does not happen ... when you run your code ?
FierceLion 22-Jan-22 7:48am    
A gadget of the old Windows speech recognition opens and it's extremely buggy and doesn't understand almost anything, while Cortana for example understand everything (same mic), I want an other way (newer) of speech recognition.
BillWoodruff 22-Jan-22 8:37am    
but, your code does not cause an error ? Try putting a break-point at the start of your code, then single-step (F11), observing the state of variables.
FierceLion 22-Jan-22 20:25pm    
There's no error, the code is right, but the speech recognition of the old engine is bad.
BillWoodruff 25-Jan-22 9:40am    
That indicates some kind of install error: you've got to identify the exact dependency that is not implemwnted, and remove the older whatever that is invoked now. Sorry I can't be more helpful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900