为什么语音识别 C# 中需要语法

Why need grammar in Speech Recognition C#

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);
 }

简而言之,为什么我们在语音识别中需要语法。如果需要语法,那有什么意义呢。如果识别器必须匹配语法中存在的字符串,为什么我们不能只输出语音识别器在没有语法的情况下识别的内容?

谢谢,不对的地方请指正。

我们使用语法来区分押韵单词或单词发音的上下文。例如你好和黄色。在 link 中有一个很好的示例解释。你好与问候语法有关,而黄色与颜色语法有关。这 提高了 efficiency/accuracy 的识别度

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.

您也可以参考 MSDN link 了解有关 Purpose of Grammars 的详细信息。

它有助于代码提供限制词汇自定义词汇过滤识别结果[=24=等功能] 和 识别规则