6

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,245
  • 10
  • 71
  • 97
Fernando Santiago
  • 2,128
  • 10
  • 44
  • 75

1 Answers1

10

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
  • 68,824
  • 13
  • 156
  • 205
  • 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
  • If your windows 10 (or higher) comes in, say, English. You can add more languages by typing "Add a language to this device", when downloading the new language, make sure you check the "Speech" option to have the speech recognizer downloaded. – Ji_in_coding May 08 '23 at 11:01