2017-07-12 9 views
1

私はUWPを使用してスマートミラーアプリケーションを作成しています。ユーザーが音声を使用してアプリケーションを制御したいと考えています。これまでのところ、私は音声認識をテストする簡単なプログラムを作ったが、うまくいきましたが、アプリケーションがキーワード「Jason」を聞いたときだけ、スピーチをテキストに変換し始めました(私はスマートミラーJason )のように: "ジェイソン、私にいくつかのニュースを見せてください"、それ以来、私はLUIS機能にテキストマッサージを渡すでしょう。文章が "Jason"で始まらない場合、アプリはそれをテキストに変換しません。それを達成するために私は何をすべきですか? 「UWP連続音声認識

private SpeechRecognizer contSpeechRecognizer; 
    private CoreDispatcher dispatcher; 
    protected async override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; 
     contSpeechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer(); 
     await contSpeechRecognizer.CompileConstraintsAsync(); 
     contSpeechRecognizer.ContinuousRecognitionSession.ResultGenerated +=ContinuousRecognitionSession_ResultGenerated; 
     contSpeechRecognizer.ContinuousRecognitionSession.AutoStopSilenceTimeout = TimeSpan.FromDays(1); 
     contSpeechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; 
     await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync(); 
    } 
    private async void ContinuousRecognitionSession_Completed(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionCompletedEventArgs args) 
    { 
     await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync(); 
    } 
    private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args) 
    {   
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal,() => 
     { 
      SpeechResult.Text = args.Result.Text; 
     }); 
    } 

答えて

1

あなただけのトリガーとして 『ジェイソン』を使用したい場合は、あなただけの

if(speechResult.Contains("Jason")||speechResult.Contains("jason")) 
{//Pass the Result to LUIS} 
を追加することができます