2017-07-11 46 views
4

到目前爲止,我還沒有在微軟網站上找到的語音識別示例有任何運氣。我也看過這個網站 - https://mtaulty.com/2016/02/08/text-to-speech-and-more-with-windows-10-uwp-project-oxford/,我嘗試使用給出的例子,它仍然無法正常工作。發生什麼事是SpeechRecognitionConfidence被拒絕(我沒有說什麼)。在你問之前,是的,我有一個工作的麥克風,一切都在設置中啓用。如何在Windows 10中正確實現語音識別UWP

有沒有簡單的東西,我在這裏失蹤?

如果你不太理解我的問題,請滾動到上面鏈接的頁面底部,並且用戶nhwilly1011遇到了同樣的問題。

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; 

我也曾嘗試微軟例如,它不工作,要麼 -

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的鏈接可能會在幾年後中斷,因此將細節包含在一個地方比較安全(在stackoverflow中)。 – kennyzx

+0

當用戶界面提示用戶說話(我說了些什麼),並且它不能識別我說的話。它承認我已經說了些什麼,但是默認了對「」所說的內容。 –

+0

@kennyzx我已經添加了代碼 - 感謝您的建議 –

回答

3

我已經找到答案了。我的電腦沒有啓用Cortana,所以我最初沒有收到錯誤消息。使用具有Cortana的計算機後,我能夠發現我使用的網絡存在問題。切換網絡後,一切都按預期工作。我的錯誤是語音識別錯誤:「無法訪問網絡」,並通過切換到不安全的WiFi連接進行修復。

1

糾正我,如果我錯過了什麼,但調用CompileConstraintsAsync之前,建議增加一個SpeechRecognitionTopicConstraintSpeechRecognizer的Constraints集合。 這是一個有益的步驟,我發現,here

+0

我包含的示例沒有SpeechRecognitionTopicConstraint,但是我也嘗試過微軟網站的示例 - 它仍然無效。 https://docs.microsoft.com/en-us/windows/uwp/input-and-devices/speech-recognition(第三個示例) –

+0

您是否遇到與正在識別的內容相同的問題或者您是否收到另一個錯誤? – Priyank

+0

這兩個問題都是同樣的問題 - 他們都沒有提到他們說的話,但他們確實提到了某些東西。 –