哇,大头衔,但是总结了这个问题。
我正在使用Microsoft SAPI在C#中工作,在我正在使用的程序中使用他们的语音识别。
我正在做的是。 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);
自定义单词。 但这会比我想要的更多。我该如何解决这个问题。
我要问的是,我怎样才能使m $ sapi只关心我想要的词。不是默认字典中的每个字。
答案 0 :(得分:0)
您可以尝试使用命令和控制模式让识别器识别您想要的单词。 对于您的代码,您只需添加
即可grammar.CmdSetRuleState( “打字”,SpeechRuleState.SGDSActive);
和 objRecoContext.State = SpeechRecoContextState.SRCS_Enabled;
希望这会有所帮助..