I am trying to get a simple speech recognition program started but it does not work, I've installed some languages (en-GB & en-US) but whenever I use the following:
SpeechRecognitionEngine.InstalledRecognizers
it returns an empty collection. Even when I just try to start a recognizer it will return "no recognizer installed". But when I reinstall a language, it says that it is already installed.
using ( SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
{
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());
// Add a handler for the speech recognized event.
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();
// Start asynchronous, continuous speech recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple);
// Keep the console window open.
while (true)
{
Console.ReadLine();
}
}
For what reason is it unable to find the installed recognizers?
Edit:
This is the exception: {System.ArgumentException: No recognizer of the required ID found. Parameter name: culture at System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo culture)
and: var recognizers = SpeechRecognitionEngine.InstalledRecognizers();
returns a collection with a count of 0
The problem was that I installed language packs that can be accessed by Microsoft.Speech
and I was using System.Speech
, when I switched to Microsoft.Speech
it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With