2013-11-21 6 views
0

windows7 시스템에서 SpeechLib.SpSharedRecoContext를 사용하면 왜 자동으로 음성 인식 도구 시스템이 열릴까요? 다음은 내 코드입니다. Windows7 시스템에서 음성 인식 도구를 실행하면 열리고 시스템 도구 시작 버튼을 클릭해야 내 프로그램이 인식을 시작할 수 있습니다.왜 Windows7 시스템에서 SpeechLib.SpSharedRecoContext를 사용하면 자동으로 음성 인식 도구 시스템이 열립니까?

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 시스템에서는이 현상이 아닙니다.

답변

0

위의 Windows Vista &에서는 공유 인식 자 (SpeechLib.SpSharedRecoContext)를 만들면 공유 인식 자의 공통 UI로 사용되는 Windows 음성 인식이 자동으로 시작됩니다. 당신이 원하지 않는 경우

, 당신은에서 프로세스 인식기 (SpeechLib.SpInProcRecoContext)를 만들 수 있습니다 - 그러나, 당신이 할 경우, 당신은 명시 적으로 오디오 소스, 인식 엔진 및 사용자 프로필 관리 할 필요가 :

private SpeechLib.SpInprocRecoContext CreateInprocRecoContext() 
{ 
    SpeechLib.SpObjectTokenCategory Category = new Speechlib.SpObjectTokenCategory(); 
    Category.SetId(SpeechLib.SpeechStringConstants.SpeechCategoryAudioIn); 

    SpeechLib.SpObjectToken AudioToken = new SpeechLib.SpObjectToken(); 
    AudioToken.SetId(Category.Default()); 

    Category.SetId(SpeechLib.SpeechStringConstants.SpeechCategoryRecognizers); 
    SpeechLib.SpObjectToken EngineToken = new SpeechLib.SpObjectToken(); 
    EngineToken.SetId(Category.Default()); 

    Category.SetId(SpeechLib.SpeechStringConstants.SpeechCategoryRecoProfiles); 
    SpeechLib.SpObjectToken ProfileToken = new SpeechLib.SpObjectToken(); 
    ProfileToken.SetId(Category.Default()); 

    SpeechLib.SpInprocRecognizer reco = new SpeechLib.SpInprocRecognizer(); 
    reco.SetRecognizer(EngineToken); 
    reco.SetInput(AudioToken); 
    reco.SetRecoProfile(ProfileToken); 

    return reco.CreateRecoContext(); 
} 
+0

대단히 감사합니다. 내가 참조. –