I tried to recognition speech in C# but it began bad. I had followed some tutorials in YouTube but this error appear every time. So I got the Microsoft MSDN code and I tried to find some solutions in Google. This is the code I'm using:
public Form1()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
// Configure the input to the recognizer.
//sre.SetInputToWaveFile(@"c:\Test\Colors.wav");
sre.SetInputToDefaultAudioDevice();
// Create a simple grammar that recognizes "red", "green", or "blue".
Choices colors = new Choices();
colors.Add(new string[] { "red", "green", "blue" });
// Create a GrammarBuilder object and append the Choices object.
GrammarBuilder gb = new GrammarBuilder();
gb.Append(colors);
// Create the Grammar instance and load it into the speech recognition engine.
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
// Register a handler for the SpeechRecognized event.
sre.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
// Start recognition.
sre.Recognize();
}
// Create a simple handler for the SpeechRecognized event.
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("Speech recognized: " + e.Result.Text);
}
I already downloaded the Microsoft Speech Platform SDK and the Runtime Languages (US). The error persists.
I also already had used this code, as I saw in a topic here in StackOverflow:
sre = new SpeechRecognitionEngine(new CultureInfo("en-GB"));
It didn't work, so I tried to use this (as I saw in MSDN):
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
When I tried to use those codes, the error change and say: "No recognizer of the required ID found". I use the Windows 7 (Home Basic, x64), Microsoft Visual C# 2010 Express. My default language (the system language also is) is Portuguese (Brazil), maybe it's the error cause? Well, thats it, I hope I wrote all detailed for you understand. Sorry for my english I'm training this, haha :P