为什么当我在windows7系统使用SpeechLib.SpSharedRecoContext,会自动打开语音识别工具,系统自带的? 以下是我的代码,当它运行在Windows7系统中的语音识别工具将打开,我必须点击系统工具开始按钮,然后我的程序就可以开始认识。
private const int grammarId = 10;
private bool speechInitialized = false;
private SpeechLib.SpSharedRecoContext objRecoContext;
private SpeechLib.ISpeechRecoGrammar grammar;
private SpeechLib.ISpeechGrammarRule ruleListItems;
private void InitializeSpeech(List<string> userKeyWords = null, bool isUseSystemGrammar = false)
{
try
{
// First of all, let's create the main reco context object.
// In this sample, we are using shared reco context. Inproc reco
// context is also available. Please see the document to decide
// which is best for your application.
objRecoContext = new SpeechLib.SpSharedRecoContext();
// Then, let's set up the event handler. We only care about
// Hypothesis and Recognition events in this sample.
objRecoContext.Hypothesis += new
_ISpeechRecoContextEvents_HypothesisEventHandler(
RecoContext_Hypothesis);
objRecoContext.Recognition += new
_ISpeechRecoContextEvents_RecognitionEventHandler(
RecoContext_Recognition);
objRecoContext.AudioLevel += new _ISpeechRecoContextEvents_AudioLevelEventHandler(objRecoContext_AudioLevel);
objRecoContext.EventInterests = SpeechRecoEvents.SREAllEvents;
// Now let's build the grammar.
grammar = objRecoContext.CreateGrammar(grammarId);
ruleListItems = grammar.Rules.Add("ListItemsRule",
SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic, 1);
RebuildGrammar(userKeyWords, isUseSystemGrammar);
// Now we can activate the top level rule. In this sample, only
// the top level rule needs to activated. The ListItemsRule is
// referenced by the top level rule.
grammar.CmdSetRuleState("ListItemsRule", SpeechRuleState.SGDSActive);
speechInitialized = true;
}
catch (Exception e)
{
Loger.LogErr(e);
}
}
如何防止我的系统工具程序的依赖?谢谢。
顺便说一句,在Windows XP系统中,这不是现象。