使用微软语音识别,我能得到一半语法被识别的时间吗?

本文关键字:识别 语法 时间 一半 语音识别 微软 | 更新日期: 2023-09-27 18:15:23

我想这样使用语法:这是+ name

代码是:

GrammarBuilder grammar = new GrammarBuilder();
grammar.Append("This is");
gammar.Append(new Choices("Bangalore", "Sanjay", "Cindy",...));
_recognizer.LoadGrammar(new Grammar(grammar));

我的问题是,当引擎识别这是时,我可以发送事件,并在引擎识别该名称时发送另一个事件吗?

如何做到这一点?

使用微软语音识别,我能得到一半语法被识别的时间吗?

我想你可以用短语

GrammarBuilder thisIsPhrase = new GrammarBuilder("This is");
Choices choices = new Choices("Dog, Cat");
GrammarBuilder endPhrase = new GrammarBuilder(choices);
Choices both = new Choices(new GrammarBuilder[] { thisIsPhrase, endPhrase });
Grammar dictationGrammar = new Grammar((GrammarBuilder)both);

查看MSDN。

我还没能测试它。

更新:选择短语似乎不起作用。

GrammarBuilder thisIsPhrase = new GrammarBuilder("This is");
GrammarBuilder endPhrase = new GrammarBuilder("Dog");  //repeat creating phrases
Choices both = new Choices(new GrammarBuilder[] { thisIsPhrase, endPhrase });//also need to add phrases here
Grammar dictationGrammar = new Grammar((GrammarBuilder)both);