Hi everyone,
I was going through a tutorial blog for speech recognition, and tried the following code Which is supposed to print "Hello world" on the screen. But it generates an error InvalidOperationException on line 16 and says "The language for the grammar does not match the language of the speech recognizer." Can anyone help me in this?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Speech.Recognition;

namespace speach
    class Program
        static void Main(string[] args)
            SpeechRecognitionEngine srEngine = new SpeechRecognitionEngine();
            Grammar gram = new Grammar("helloworld.xml");
            srEngine.LoadGrammar(gram);  // error here!
            srEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(srEngine_SpeechRecognized);

        static void srEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
            Console.WriteLine("Detected: " + e.Result.Text);

Member Avatar

My best guess is that there's a mistake somewhere in helloworld.xml.

Double check that everything's formatted correctly and the syntax is correct.