2015-02-07 7 views
0

우리는 논문 개정을 받았으며 한 음성 토론자는 음성 인식 시스템을 개선하는 것이 명령을 처리하는 방법을 추가하는 것이라고 말했습니다.비동기 적으로 음성으로 명령 실행

예를 들어 나는 시스템이 사용자가 다른 명령을 제공 할 수 있습니다 전에 명령이 여전히 처리하고있는 사용자를 말할 수있을하고자하는 기본 명령

case "What time is it?": 
WVASRS.Speak("time"); 
break; 

에게 제공합니다. 뭔가 같은 :

//I will give a command while the the other command is processing 
case "What day is it": 
WVASRS.Speak("day"); 
break; 

WVASRS.Speak("Another command is still processing. Please Wait for a few seconds before you can give another command."); 

글쎄, MSDN에서 뭔가 발견하면 그냥 아무것도하지 않습니다. 여기에 코드 조각은 다음과 같습니다

// Assign input to the recognizer and start asynchronous 
    // recognition. 
    recognizer.SetInputToDefaultAudioDevice(); 

    completed = false; 
    Console.WriteLine("Starting asynchronous recognition..."); 
    recognizer.RecognizeAsync(RecognizeMode.Multiple); 

    // Wait 30 seconds, and then cancel asynchronous recognition. 
    Thread.Sleep(TimeSpan.FromSeconds(30)); 
    recognizer.RecognizeAsyncCancel(); 

    // Wait for the operation to complete. 
    while (!completed) 
    { 
     Thread.Sleep(333); 
    } 
    Console.WriteLine("Done."); 
+0

아무것도하지 않으면 프로그램이 실행되고 speechRecognizer가 작업을 완료하기 전에 종료됩니다. 일어난 일에 대한 자세한 내용을 추가 할 수 있다면 도움이 될 것입니다. –

답변

0

MSDN에서의 코드는, 당신은 단지 전체 예제 here를 참조 인식 명령의 핸들러를 그리워 다소 정확 :

recognizer.SpeechRecognized += 
      new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized); 

이후

// Handle the SpeechRecognized event. 
static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) 
{ 

    if (actionRunning) { 
     speak("Busy"); 
    } 
    if (e.Result.Text.Equals("what is the time")) { 
     actionRunning = true; 
     startAction() 
    } 
    Console.WriteLine("Speech recognized: " + e.Result.Text); 
} 
관련 문제