c# - 使用microsoft speech recognition,我能得到语法识别到一半的时间吗?

标签 c# speech-recognition system.speech.recognition

我想使用这样的语法:This is + name

代码是:

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

我的问题是,我能否在引擎识别出 This is 时发送事件,并在引擎识别出名称时发送另一个事件?

如何做到这一点?

最佳答案

我想你可以通过使用短语来做到这一点

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 .

虽然我还没有能够测试它。

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

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

关于c# - 使用microsoft speech recognition,我能得到语法识别到一半的时间吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25006441/

相关文章:

c# - 使用 LINQ 按索引对两个列表进行分组

c# - 适用于 Windows x64 的 ASP.NET Core 应用程序(.NET Framework)仅在 project.assets.json 中出错

java - 在 Android 上限制语音识别结果

c# - System.Speech.Recognition 的问题 - SpeechRecognitionEngine 不接收语音

c# - 让语音识别从句子中挑选一个单词

C# 无法访问 Enum 类变量

c# - 从 vm azure c# 分离磁盘

java - 如何在 Sphinx 4(语音识别)中添加用户可以选择的关键字?

audio - YouTube语音识别-音频中包含特殊单词?