C# 和 SAPI,我有语音识别功能,但它拾取的单词我不感兴趣。我如何限制语法词典,而不仅仅是超重?
哇,标题很大,但是,这总结了问题。
我使用 Microsoft SAPI 使用 C# 进行工作,在我正在开发的程序中使用他们的语音识别功能。
我让它做的是。 语法 = objRecoContext.CreateGrammar(0);
menuRule = grammar.Rules.Add("typewrite", SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic, 1);
object PropValue = "";
menuRule.InitialState.AddWordTransition(null, "will", " ", SpeechGrammarWordType.SGLexical, "will", 1, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "New", " ", SpeechGrammarWordType.SGLexical, "New", 1, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "Open", " ", SpeechGrammarWordType.SGLexical, "Open", 2, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "Close", " ", SpeechGrammarWordType.SGLexical, "Close", 3, ref PropValue, 1.0F);
对于自定义单词。 但这会比我想要的更多。 我怎样才能解决这个问题。
我问的是,我怎样才能让 m$ sapi 只关心我想要的单词。 不是默认字典中的每个单词。
Whew, big title, but yea that sums up the question.
Im working in C# with the Microsoft SAPI, using their speech Recognition in a program im working on.
what i have it doing is.
grammar = objRecoContext.CreateGrammar(0);
menuRule = grammar.Rules.Add("typewrite", SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic, 1);
object PropValue = "";
menuRule.InitialState.AddWordTransition(null, "will", " ", SpeechGrammarWordType.SGLexical, "will", 1, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "New", " ", SpeechGrammarWordType.SGLexical, "New", 1, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "Open", " ", SpeechGrammarWordType.SGLexical, "Open", 2, ref PropValue, 1.0F);
menuRule.InitialState.AddWordTransition(null, "Close", " ", SpeechGrammarWordType.SGLexical, "Close", 3, ref PropValue, 1.0F);
for custom words.
but this will pick up more than I want. how can i fix this.
what im asking is, how can i make the m$ sapi only care about words I want it to. not every word in the default dict.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用命令和控制模式,让识别器仅识别您想要的单词。
对于您的代码,您需要做的就是添加
Grammar.CmdSetRuleState("typewrite",SpeechRuleState.SGDSActive);
和
objRecoContext.State = SpeechRecoContextState.SRCS_Enabled;
希望这可以帮助..
You can try using Command and Control mode for the recognizer to recognize just the words that you want.
For your code, all you need to do is add
grammar.CmdSetRuleState("typewrite",SpeechRuleState.SGDSActive);
and
objRecoContext.State = SpeechRecoContextState.SRCS_Enabled;
Hope this helps..