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.SetInputToWaveFile("helloworld.wav");
srEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(srEngine_SpeechRecognized);
srEngine.Recognize();
}
static void srEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine("Detected: " + e.Result.Text);
}
}
}