5

I am working on a program (in C#) to recognize voice commands from the user and execute in the PC, i.e. the user says "start menu" and the PC opens the start menu.

I have find a cool library: SpeechRecognitionEngine for the speech recognition, the problem is that I need to recognize spanish language too, is there any way to change the language?

Matthew Frederick
  • 22,127
  • 10
  • 70
  • 97
Fernando Santiago
  • 1,960
  • 8
  • 43
  • 70

1 Answers1

9

You can use the SpeechRecognitionEngine(CultureInfo) overload.

var speechRec = new SpeechRecognitionEngine(new CultureInfo("es-ES")));

This assumes that the user has the Spanish culture installed, otherwise an ArgumentException will be thrown. The SpeechRecognitionEngine class implements IDisposable, so it's a good idea to call speechRec.Dispose() when you're done, or use it in a using statement.

keyboardP
  • 67,723
  • 13
  • 149
  • 201
  • what is "Spanish culture" do you mean the windows is in spanish? – Fernando Santiago Dec 20 '12 at 22:29
  • Yes, the user needs to have the Spanish speech recognizer installed. If you buy a Windows PC in Spain, I'm guessing this is installed as standard but I don't have the Spanish one on my PC (in the UK) so if I was to run that code, I'd get an exception. I believe Windows 7 Ultimate users can download additional language packs. If you don't specify a culture, it will use the default one installed on the user's machine. – keyboardP Dec 20 '12 at 22:35
  • oooh, i got it, thank you man! btw is there any other way to recognize voice in c#? – Fernando Santiago Dec 20 '12 at 22:47
  • No problem. There are other third party libraries, but the SpeechRecognitionEngine is from Microsoft and is actually quite good IMHO. I'm using it in my current project. You can use `System.Speech` or `Microsoft.Speech` (http://stackoverflow.com/questions/2977338/what-is-the-difference-between-system-speech-recognition-and-microsoft-speech-re). Both have pros and cons. – keyboardP Dec 20 '12 at 22:50