I’m trying to recognize simple english words, but no recognition occur.
private void Form1_Load(object sender, EventArgs e)
{
SpeechRecognitionEngine srEngine = new SpeechRecognitionEngine();
// Create a simple grammar that recognizes "twinkle", "little", "star"
Choices song_00 = new Choices();
song_00.Add(new string[] {"twinkle", "little", "star"});
// Create a GrammarBuilder object and append the choices object
GrammarBuilder gb = new GrammarBuilder();
gb.Append(song_00);
// Create the grammar instance and load it into the sppech reocognition engine.
Grammar g = new Grammar(gb);
g.Enabled = true;
srEngine.LoadGrammar(g);
srEngine.SetInputToDefaultAudioDevice();
// Register a handler for the Speechrecognized event.
srEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
srEngine.RecognizeAsync(RecognizeMode.Multiple);
}
// Create a simple handler for the SpeechRecognized event.
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("Speech recognized: " + e.Result.Text);
}
Below one does not show any message, too.
foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
MessageBox.Show(ri.Culture);
}
So the main reason of failing that I can think is language.
Is there any solution to use english recognition in non-english version of windows?
or
Is there problems that I couldn’t notice?
- Now I’m using non-english version of windows7(64-bit), and my mic is connected well. (I already checked the control panel.)
You have simple choices defined, but you don’t mention what exactly you are trying to match. Microsoft Speech uses a confidence scale in order to decide if it heard a phrase, and you may not be hitting this mark when you are speaking.
Add a callback for
SpeechRecognitionRejectedandSpeechHypothesized. See if they are firing and what information is coming out of them. It will help you debug.Simply looking for the words “twinkle”, “little” and “star” will not allow you capture “Twinkle, twinkle, little star”. It will capture those words as singletons, but as soon as you start stringing them together and adding new words the confidence level will go down and you will have a much lower chance of getting the result you want.
In addition to
Choicesyou should also be defining phrases that use those choices and put them into context. TheGrammerBuilderclass documentation at MSDN gives an example:Notice that the code does not assume that “Set background to blue” will be captured. It explicitly sets that condition up.