I'm trying to build software that interprets various textual commands, all in a custom way. I use System.Speech.Recognition and it works surprisingly well, but I can't figure how to get around the fact that whenever I say "Delete", "Close", "Correct", etc, I will end up with the default Windows (7) implementation. Is there any way to get around that with System.Speech.Recognition? If not, which C# .NET library would you recommend the most?
Asked
Active
Viewed 2,610 times
1 Answers
13
Use SpeechRecognitionEngine instead of SpeechRecognizer.
Try this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
namespace speech
{
class Program
{
static void Main(string[] args)
{
SpeechRecognitionEngine mynizer = new SpeechRecognitionEngine();
GrammarBuilder builder = new GrammarBuilder();
builder.AppendDictation();
Grammar mygram = new Grammar(builder);
mynizer.SetInputToDefaultAudioDevice();
mynizer.LoadGrammar(mygram);
while (true)
{
Console.WriteLine(mynizer.Recognize().Text);
}
}
}
}

bbosak
- 5,353
- 7
- 42
- 60
-
Pointing the recognizer to the default microphone and use an event handler instead of endless loop: `mynizer.SpeechRecognized += HandleSpeechRecognized; mynizer.SetInputToDefaultAudioDevice(); mynizer.RecognizeAsync(RecognizeMode.Multiple);` – Marcel Sep 05 '19 at 19:54