简体   繁体   English

为什么在语音识别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);
 }

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. 谢谢,并且在我错了的地方请你纠正。

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 . 您还可以参考MSDN链接以了解有关Grammars目的的详细信息。

It helps code to provide functionalities like Limits Vocabulary , Customizes Vocabulary , Filters Recognition Results and Identifies Rules . 它有助于代码提供限制词汇自定义词汇过滤器识别结果标识规则等功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM