rakagunarto
rakagunarto

Reputation: 315

SpeechRecognitionEngine recognizers

I just downloaded the fr-FR runtime language pack so that I can recognize French speech through my program.

However, my program throws the error

Additional information: No recognizer of the required ID found.

at

SpeechRecognitionEngine recognizer = 
    new SpeechRecognitionEngine(new System.Globalization.CultureInfo("fr-FR"));

en-US and en-GB works because they are pre-installed with my system, I just installed these new language packs but they are still throwing this exception.

Also, if this helps, when I do

foreach (var x in SpeechRecognitionEngine.InstalledRecognizers())
{
    Console.Out.WriteLine(x.Name);
}

it prints

MS-1033-80-DESK

EDIT: This is not a possible duplicate because this isn't about having no recognizers installed, it's about C# SAPI not seeing that I have the installed pack for the current language

Upvotes: 3

Views: 4640

Answers (3)

agaertner
agaertner

Reputation: 1

For those wanderers on the internet working with System.Speech.Recognizer:

SpeechRecognitionEngine.InstalledRecognizers();

does not reliably work for System.Speech. You can have the culture installed and your SpeechRecognizerEngine may still crash on construction because a speech component is missing.

However, there is a better way than that anyway.

To test if Speech Recognition component is installed for the target culture just test it on a temporary SpeechRecognitionEngine. There is no reason not to. Creating multiple engines won't crash your app and it's fast.

public static bool TestVoiceLanguage(CultureInfo culture) {
    try {
        using var tempRecognizer = new SpeechRecognitionEngine(culture);
        return true;
    } catch (ArgumentException) {
        // None of the installed speech recognizers support the specified locale, or 
        // culture is the invariant culture.
        return false;
    }
}

You may also want to redirect your users to the Speech control panel with

Process.Start("ms-settings:speech");

References

Upvotes: 0

DrewJordan
DrewJordan

Reputation: 5314

I was able to get this to work... there is an extra step involved.

Since you're using System.Speech, it uses the installed Desktop speech recognition that comes with Windows. The error you're getting is not because you don't have the language installed, but because you didn't install the speech recognizer for that language.

So, head on over to Setting > Time and Language > Region and language (which is probably where you installed the language from). After you install the language, select the language, and click 'Options'. You should see options to download the language pack, spell checking, and the one we're interested in, Speech. Click Download, and wait for the download/install to finish.

Once it's done, you won't get a notification, but you can go into Settings > Time and Language > Speech and see your installed recognizers there, or you can go to Settings > Speech Recognition > Advanced Speech Options to see the same list.

Now when you run your program, it should work. BTW, if you want to see the installed speech recognizers in your code, use this instead:

foreach (var x in SpeechRecognitionEngine.InstalledRecognizers())
            {
                Console.WriteLine(x.Culture.Name);   
            }

You only get a code when asking for the recognizers name, you want the culture's name. (as you saw, MS-1033-80-DESK corresponds to en-US. For reference, fr-FR is MS-1036-80-DESK).

Upvotes: 4

user1575095
user1575095

Reputation:

Is it possible that you installed the Microsoft Speech Platform French language pack? Such as the ones seen here? MS Speech Platform Language Packs

If that's the case then it won't appear as an installed language for what you're doing. To get it to work, from what I understand, you will need a language pack installed for French instead which is only available for Windows Ultimate and Enterprise editions if you're using a non-French version of windows.

If that's impossible, then you might have to figure out how to use the Microsoft Speech Platform SDK vs Windows/SAPI. Right now it seems like you're trying to use Windows/SAPI with a Speech Platform Recognizer. Here's the MS page the shows the difference between the MS Speech Platform vs. Windows/SAPI

Upvotes: 3

Related Questions