I'm having a problem with Microsoft.Speech.Recognition
and also with System.Speech.Recognation;
Well, I was able to run the application to support the English language, which in the case is standard in my OS, which is Windows 8.1 (x64), my SO is in English.
This is what I want to do is to recognize sounds in Portuguese, but for this I had to install these 4 elements in my OS:
- Microsoft Speech Platform SDK,
- MSSpeech_SR_en-US_TELE,
- SpeechPlatformRuntime MSSpeech_TTS_en-BR_Heloisa,
What I saw in a tutorial on youtube, good then I tried to run using Microsoft.Speech.Recognation
gave this error:
Speech Recognition is not available on this system. SAPI and Speech Recognition engines can not be found.
So I tried to use this System.Speech.Recognation
and I passed the instance of class Recognation
Culture to Portuguese Brazil.
SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("pt-Br"));
But he gave this other error:
No recognizer installed.
I do not know if there is a problem with the Speech Recognition of windows, because on computers that are installed in Portuguese, there are 3 languages in the speech recognition, there in the Control Panel.
Well, I kind of wanted at least one of them to work.
Here is a little code below:
private void btnEnable_Click(object sender, EventArgs e)
{
recEngine.RecognizeAsync(RecognizeMode.Multiple);
btnDisable.Enabled = true;
}
private void btnDisable_Click(object sender, EventArgs e)
{
recEngine.RecognizeAsyncStop();
btnDisable.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
Choices commands = new Choices();
commands.Add(new string[] { "carro", "print my name" , "joab" , "maria"});
GrammarBuilder gBuilder = new GrammarBuilder();
gBuilder.Append(commands);
Grammar gramar = new Grammar(gBuilder);
recEngine.LoadGrammarAsync(gramar);
recEngine.SetInputToDefaultAudioDevice();
recEngine.SpeechRecognized += recEngine_SpeechRecognized;
}
private void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
switch (e.Result.Text) {
case "carro":
MessageBox.Show("Hello Jhon how are you ?");
break;
case "print my name":
richTextBox1.Text += "Johon";
break;
case "joab":
MessageBox.Show("Acertou Joab");
break;
case "maria":
MessageBox.Show("Acertou Maria");
break;
}
}
Remembering that this takes English.