I'm trying to use the .NET SpeechRecognitionEngine with C# in VisualStudio Express. However i'm finding that it's picking up completely wrong words / sentences and assuming they are something in the grammar.
EG If I load "test 1" into the grammar and say "filthy beast" which is not even close to the words "test 1", the EventHandler SpeechRecognized fires. I left a movie playing on netflix while coding and it was firing the recognized event to music and talk in the movie, so it's way way off.
Is there a way to prevent it from assuming the spoken words are in the grammar? Or any way to stop this?
Any tips?
Here is a log output for me saying "filthy beast" when the grammar only has "test 1" loaded into it.
speechDetectedHandler():
speechHypothesizedHandler(): confidence = 0.002903746 e.Result.Text = Test
speechHypothesizedHandler(): confidence = 0.8096436 e.Result.Text = Test
speechRecognizedHandler(): confidence = 0.7723699 e.Result.Text = Test 1
Code:
public SpeechRecognitionEngine sre;
String culture = "en-US";
foreach (RecognizerInfo config in SpeechRecognitionEngine.InstalledRecognizers())
{
if (config.Culture.ToString() == culture)
{
s = new SpeechRecognitionEngine(config);
break;
}
}
s.SetInputToDefaultAudioDevice();
sre.MaxAlternates = 0;
sre.AudioLevelUpdated += new EventHandler<AudioLevelUpdatedEventArgs>(audioLevelHandler);
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechRecognizedHandler);
sre.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(speechHypothesizedHandler);
sre.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(speechDetectedHandler);
gb = new GrammarBuilder(speechCommands);
g = new Grammar(gb);
sre.UnloadAllGrammars();
sre.LoadGrammar(g);
startListening();