到目前爲止,我還沒有在微軟網站上找到的語音識別示例有任何運氣。我也看過這個網站 - 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();
}
請編輯您的問題提供錯誤的詳細信息。到mtaulty.com的鏈接可能會在幾年後中斷,因此將細節包含在一個地方比較安全(在stackoverflow中)。 – kennyzx
當用戶界面提示用戶說話(我說了些什麼),並且它不能識別我說的話。它承認我已經說了些什麼,但是默認了對「」所說的內容。 –
@kennyzx我已經添加了代碼 - 感謝您的建議 –