1

唷,大标题,但是是的,它总结了这个问题。

我在 C# 中使用 Microsoft SAPI,在我正在处理的程序中使用他们的语音识别。

我所做的是。语法 = 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 只关心我想要的单词。不是默认字典中的每个单词。

4

1 回答 1

0

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

语法.CmdSetRuleState("打字",SpeechRuleState.SGDSActive);

和 objRecoContext.State = SpeechRecoContextState.SRCS_Enabled;

希望这可以帮助..

于 2009-03-13T01:40:03.967 回答