C# 和 SAPI,我有语音识别功能,但它拾取的单词我不感兴趣。我如何限制语法词典,而不仅仅是超重?

发布于 2024-07-14 11:35:45 字数 1004 浏览 4 评论 0原文

哇,标题很大,但是,这总结了问题。

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不吻晚风 2024-07-21 11:35:46

您可以尝试使用命令和控制模式,让识别器仅识别您想要的单词。
对于您的代码,您需要做的就是添加

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..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文