2017-07-11 34 views
4

これまでのところ私はマイクロソフトのウェブサイトで見つかった音声認識の例について何の不運も感じていません。私もこのウェブサイトを見ました - https://mtaulty.com/2016/02/08/text-to-speech-and-more-with-windows-10-uwp-project-oxford/と私は与えられた例を使ってみましたが、それはまだ動作しません。何が起こっているのは、SpeechRecognitionConfidenceが拒否されたことです(私が何も言わなかったことです)。あなたが聞く前に、私は動作中のマイクを持っており、すべてが設定で有効になっています。Windows 10で音声認識を正しく実装する方法UWP

私はここで欠けていることがありますか?

あなたが私の質問を理解できない場合は、上記のリンク先のページの下にスクロールし、ユーザーnhwilly1011は同じ問題が発生しています。私はまた、Microsoftの例を試してみましたが、それはどちらか動作しません

async void Button_Click_2(object sender, RoutedEventArgs e) 
    { 
     this.recognizer = new SpeechRecognizer(); 
     await this.recognizer.CompileConstraintsAsync(); 

     this.recognizer.Timeouts.InitialSilenceTimeout = TimeSpan.FromSeconds(5); 
     this.recognizer.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(20); 

     this.recognizer.UIOptions.AudiblePrompt = "Say whatever you like, I'm listening"; 
     this.recognizer.UIOptions.ExampleText = "The quick brown fox jumps over the lazy dog"; 
     this.recognizer.UIOptions.ShowConfirmation = true; 
     this.recognizer.UIOptions.IsReadBackEnabled = true; 
     this.recognizer.Timeouts.BabbleTimeout = TimeSpan.FromSeconds(5); 

     var result = await this.recognizer.RecognizeWithUIAsync(); 

     if (result != null) 
     { 
      StringBuilder builder = new StringBuilder(); 

      builder.AppendLine(
       $"I have {result.Confidence} confidence that you said [{result.Text}] " + 
       $"and it took {result.PhraseDuration.TotalSeconds} seconds to say it " + 
       $"starting at {result.PhraseStartTime:g}"); 

      var alternates = result.GetAlternates(10); 

      builder.AppendLine(
       $"There were {alternates?.Count} alternates - listed below (if any)"); 

      if (alternates != null) 
      { 
       foreach (var alternate in alternates) 
       { 
        builder.AppendLine(
         $"Alternate {alternate.Confidence} confident you said [{alternate.Text}]"); 
       } 
      } 
      this.txtResults.Text = builder.ToString(); 
     } 
    } 
    SpeechRecognizer recognizer; 

- 私は何かを逃しましたが、CompileConstraintsAsyncを呼び出す前に、SpeechRecognitionTopicConstraintを追加することが推奨されている場合

private async void Button_Click_1(object sender, RoutedEventArgs e) 
    { 
     // Create an instance of SpeechRecognizer. 
     var speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer(); 

     //// Listen for audio input issues. 
     //speechRecognizer.RecognitionQualityDegrading += speechRecognizer_RecognitionQualityDegrading; 

     // Add a web search grammar to the recognizer. 
     var webSearchGrammar = new Windows.Media.SpeechRecognition.SpeechRecognitionTopicConstraint(Windows.Media.SpeechRecognition.SpeechRecognitionScenario.WebSearch, "webSearch"); 


     speechRecognizer.UIOptions.AudiblePrompt = "Say what you want to search for..."; 
     speechRecognizer.UIOptions.ExampleText = @"Ex. 'weather for London'"; 
     speechRecognizer.Constraints.Add(webSearchGrammar); 


     // Compile the constraint. 
     await speechRecognizer.CompileConstraintsAsync(); 

     // Start recognition. 
     Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync(); 
     await speechRecognizer.RecognizeWithUIAsync(); 

     // Do something with the recognition result. 
     var messageDialog = new Windows.UI.Popups.MessageDialog(speechRecognitionResult.Text, "Text spoken"); 
     await messageDialog.ShowAsync(); 
    } 
+1

ご質問を編集してください。エラーの詳細をご記入ください。 mtaulty.comへのリンクは数年後に中断する可能性があるので、詳細を1つの場所(stackoverflow内)に含める方が安全です。 – kennyzx

+0

UIがユーザーに発言するように促すと(私は何かを言う)、私が話したことを認識しません。それは私が何か言ったことを認識しますが、話されたものの出力をデフォルトにします。 –

+0

@kennyzxコードを追加しました - お礼ありがとうございます –

答えて

3

私は答えを見つけました。私のコンピュータはCortanaで有効になっていなかったので、最初はエラーメッセージが表示されませんでした。 Cortanaを持っているコンピュータを使用した後、私が使用していたネットワークに問題があることがわかりました。ネットワークを切り替えると、すべてが期待どおりに機能しました。音声認識でエラーが発生しました:「ネットワークにアクセスできない」というエラーが発生し、セキュリティ保護されていないWiFi接続に切り替えることで修正されました。

1

は私を修正しますSpeechRecognizerのConstraintsコレクション。 ここに私が見つけた役に立つウォーキングがあります。here

+0

私が含まれている例にはSpeechRecognitionTopicConstraintはありませんが、MicrosoftのWebサイトの例を試してみましたが、それでも機能しません。 https://docs.microsoft.com/en-us/windows/uwp/input-and-devices/speech-recognition(3番目の例) –

+0

認識されているものと同じ問題が発生しているのですか、別のエラーが発生していますか? – Priyank

+0

両者とも同じ問題です。彼らはどちらも言われていることを拾いませんが、何かが拾い上げられたと言われました。 –