Search code examples
c#speech-recognitionspeech

Change the language of Speech Recognition Engine library


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?


Solution

  • 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.