1
votes
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
Choices clist = new Choices();
// just assume I have added words in clist not shown here
Grammar gr = new Grammar(new GrammarBuilder(clist));

sre.RequestRecognizerUpdate();
sre.LoadGrammar(gr);
sre.SpeechRecognized += sre_SpeechRecognized;
sre.SetInputToDefaultAudioDevice();
sre.RecognizeAsync(RecognizeMode.Multiple);

 void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
//This only outputs words present in grammar
   Console.WriteLine(e.Result.Text);
 }

In short why do we need a grammar in speech recognition. Whats the point if a grammar is needed. If the recognizer has to match strings present in grammar, why can't we just output what the speech recognizer recognized without grammar?

Thanks and kindly correct me where i'm wrong.

1

1 Answers

3
votes

We use grammar to make difference in context for rhyming words or how the word was pronounced. Example hello and yellow. There is a nice explanation with sample at the link. Hello relates to greetings grammar while yellow relates to color grammar. This improves efficiency/accuracy of recognition.

If the grouping inside of grammar rules or grammars are clever, developers can enable and disable scenarios when the system moves into a specific state. It can give context and, in some cases, better accuracy for the words the system is listening for.

You can also refer MSDN link to understand the detail on the Purpose of Grammars.

It helps code to provide functionalities like Limits Vocabulary, Customizes Vocabulary, Filters Recognition Results and Identifies Rules.