Error "No recognizer is installed" with recognition speech [duplicate] - c#

This question already has an answer here:
SpeechRecognitionEngine.InstalledRecognizers returns No recognizer installed
(1 answer)
Closed 8 years ago.
I tried to recognition speech in C# but it began bad. I had followed some tutorials in YouTube but this error appear every time. So I got the Microsoft MSDN code and I tried to find some solutions in Google. This is the code I'm using:
public Form1()
{
InitializeComponent();
Initialize();
}
private void Initialize()
{
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
// Configure the input to the recognizer.
//sre.SetInputToWaveFile(#"c:\Test\Colors.wav");
sre.SetInputToDefaultAudioDevice();
// Create a simple grammar that recognizes "red", "green", or "blue".
Choices colors = new Choices();
colors.Add(new string[] { "red", "green", "blue" });
// Create a GrammarBuilder object and append the Choices object.
GrammarBuilder gb = new GrammarBuilder();
gb.Append(colors);
// Create the Grammar instance and load it into the speech recognition engine.
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
// Register a handler for the SpeechRecognized event.
sre.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
// Start recognition.
sre.Recognize();
}
// Create a simple handler for the SpeechRecognized event.
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("Speech recognized: " + e.Result.Text);
}
I already downloaded the Microsoft Speech Platform SDK and the Runtime Languages (US). The error persists.
I also already had used this code, as I saw in a topic here in StackOverflow:
sre = new SpeechRecognitionEngine(new CultureInfo("en-GB"));
It didn't work, so I tried to use this (as I saw in MSDN):
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
When I tried to use those codes, the error change and say: "No recognizer of the required ID found".
I use the Windows 7 (Home Basic, x64), Microsoft Visual C# 2010 Express. My default language (the system language also is) is Portuguese (Brazil), maybe it's the error cause?
Well, thats it, I hope I wrote all detailed for you understand. Sorry for my english I'm training this, haha :P

Run the following to determine what recognizers you have installed, breakpoint / debug and inspect if you need to
foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
System.Diagnostics.Debug.WriteLine(ri.Culture.Name);
}
And use one of the listed cultures in the SpeechRecognitionEngine constructor

Related

SpeechRecognitionEngine Error HRESULT E_FAIL has been returned from a call to a COM component

I'm running some simple main method code that instantiates a SpeechRecognitionEngine and passes some grammar data to it. I can't seem to find why the error keeps coming up. I tried deleting the .csproj and .suo and nothing changed.
SpeechRecognitionEngine spe = new SpeechRecognitionEngine();
Choices commands = new Choices();
commands.Add("hello", "what is your name");
GrammarBuilder gB = new GrammarBuilder(commands);
Grammar g = new Grammar(gB);
//every single call to spe.SomeMethod() breaks with the error in the title
spe.LoadGrammarAsync(g);
spe.SetInputToDefaultAudioDevice();
spe.RecognizeAsync(RecognizeMode.Multiple);
Alright, figured it out:
Go to:
Build>Configuration Manager>Active Solution Platform
Click the 'Any CPU' dropdown.
Select
Set the platform to the compatible Speech SDK type (in my case x64)
enjoy your robotic servant program in the making
ps. save yourself the headache and use RecognizeAsync() and not Recognize(). Recognize likes to proc twice for some reason.

Speech Recognition is not available on this system. SAPI and Speech Recognition engines cannot be found

Good day!
I try to write simple speech to text engine use Speech SDK 11.
So try to execute test from this example .
So , i just create console app and run code. (with task)
Task speechRecognizer = new Task(DoWork);
speechRecognizer.Start();
speechRecognizer.Wait();
static void DoWork()
{
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
// Configure the input to the recognizer.
sre.SetInputToWaveFile(#"c:\Test\Colors.wav");
// Create a simple grammar that recognizes "red", "green", or "blue".
Choices colors = new Choices();
colors.Add(new string[] { "red", "green", "blue" });
// Create a GrammarBuilder object and append the Choices object.
GrammarBuilder gb = new GrammarBuilder();
gb.Append(colors);
// Create the Grammar instance and load it into the speech recognition engine.
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
// Register a handler for the SpeechRecognized event.
sre.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
// Start recognition.
sre.Recognize();
}
But i get this exception:Speech Recognition is not available on this system. SAPI and Speech Recognition engines cannot be found.I try to install SpeechSDK51 ,but have no result.
Can you tell me how to fix this error?
Thank you!
P.S. Error arises at :
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
Did you add both the x64 and the x86 versions of the runtime component? It worked for me.
Faced the same issue. The runtime wasn't installed. Installing the runtime from microsoft official download page resolved my issue.

Accuracy of MS System.Speech.Recognizer and the SpeechRecognitionEngine

I am currently testing the SpeechRecognitionEngine by loading from an xml file a pretty simple rule. In fact it is a simple between ("decrypt the email", "remove encryption") or ("encrypt the email", "add encryption").
I have trained my Windows 7 PC and additionally added the words encrypt and decrypt as I realize they are very similar. The recognizer already has a problem with making a difference between these two.
The issue I am having is that it recognizes things too often. I have set the confidence to 0.93 because with my voice in a quiet room when saying the exact words sometimes only gets to 0.93. But then if I turn on the radio the voice of the announcer or a song can mean that this recognizer thinks it has heard with over 0.93 confidence with words "decrpyt the email".
Maybe Lady Gaga is backmasking Applause to secretly decrypt emails :-)
Can anyone help in working out how to do something to make this recognizer workable.
In fact the recognizer is also picking up keyboard noise as "decrypt the email". I don't understand how this is possible.
Further to my editing buddy there are at least two managed namespaces for MS Speech Microsoft.Speech and System.Speech - It is important for this question that it be know that it is System.Speech.
If the only thing the System.Speech recognizer is listening for is "encrypt the email", then the recognizer will generate lots of false positives. (Particularly in a noisy environment.) If you add a DictationGrammar (particularly a pronunciation grammar) in parallel, the DictationGrammar will pick up the noise, and you can check the (e.g.) name of the grammar in the event handler to discard the bogus recognitions.
A (subset) example:
static void Main(string[] args)
{
Choices gb = new Choices();
gb.Add("encrypt the document");
gb.Add("decrypt the document");
Grammar commands = new Grammar(gb);
commands.Name = "commands";
DictationGrammar dg = new DictationGrammar("grammar:dictation#pronunciation");
dg.Name = "Random";
using (SpeechRecognitionEngine recoEngine = new SpeechRecognitionEngine(new CultureInfo("en-US")))
{
recoEngine.SetInputToDefaultAudioDevice();
recoEngine.LoadGrammar(commands);
recoEngine.LoadGrammar(dg);
recoEngine.RecognizeCompleted += recoEngine_RecognizeCompleted;
recoEngine.RecognizeAsync();
System.Console.ReadKey(true);
recoEngine.RecognizeAsyncStop();
}
}
static void recoEngine_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
{
if (e.Result.Grammar.Name != "Random")
{
System.Console.WriteLine(e.Result.Text);
}
}

SpeechRecognitionEngine.InstalledRecognizers returns No recognizer installed

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.

C# Speech recognition error - The language for the grammar does not match the language of the speech recognizer

I have problem with my speech recognition.
It works on "English" windows with no problem.
It also works on some "Foreign" windows too. But only some.
I'm getting that exception:
The language for the grammar does not match the language of the speech recognizer
I added my own words to dictionary.
How can I fix it?
Not sure which version .net you are on, but I'll attempt to answer.
On your English Windows version, please navigate to C:\Program Files\Reference Assemblies\Microsoft\Framework[YOUR .NET VERSION]
You should find System.Speech.dll,
Make sure to bring this .dll over to your foreign computer, and everything should run smoothly.
I had the same problem on my friends Computer. So I made this (it is just part of the code, because all the code is really long ):
...
RecognizerInfo recognizerInfo = null;
foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
if ((ri.Culture.TwoLetterISOLanguageName.Equals("en")) && (recognizerInfo == null))
{
recognizerInfo = ri;
break;
}
}
SpeechRecognitionEngine SpeachRecognition = new SpeechRecognitionEngine(recognizerInfo);
GrammarBuilder gb = new GrammarBuilder(startLiserninFraze);
gb.Culture = recognizerInfo.Culture;
grammar = new Grammar(gb);
SpeachRecognition.RequestRecognizerUpdate();
SpeachRecognition.LoadGrammar(grammar);
SpeachRecognition.SpeechRecognized += SpeachRecognition_SpeechRecognized;
SpeachRecognition.SetInputToDefaultAudioDevice();
SpeachRecognition.RecognizeAsync(RecognizeMode.Multiple);
...
So this should work. My friends PC supported 2 instances of "en" or in "eng". Not sure why. So the code selects first one. I found some pieces of code on the internet and some of this is made by me.
SpeachRecognition.SpeechRecognized += SpeachRecognition_SpeechRecognized;
is made to make an event when everything is recognized. just type:
SpeachRecognition.SpeechRecognized +=
and the press TAB button (atleast in VS 2013) few times. and then in the bottom of code it will generate something like this:
void SpeachRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//then will be some line that you need to replace with your code
}
I hope this will help. :)

Categories

Resources