設定語音辨識超時時間

設定語音辨識器忽略靜默或難以辨識的聲音(如咿呀聲)並持續聆聽語音輸入的時間。

Important

語音辨識需要 MSIX 套件的識別碼。 Windows.Media.SpeechRecognition這些 API 只有在你的應用程式以套件身份(打包或以外部位置打包)執行時才可用。 未封裝的應用程式無法使用這些 API。

主要 API

概觀

SpeechRecognizer.Timeouts 屬性會傳回一個 SpeechRecognizerTimeouts 物件,其中包含三個可設定的 TimeSpan 值:

房產 Description
初始沉默暫停 SpeechRecognizer 在判定後續不會有語音輸入並完成空結果之前,會偵測靜音多久。
結束沉默 暫停 SpeechRecognizer 在辨識到語音後,在將結果定案前會持續偵聽靜音多久。
BabbleTimeout SpeechRecognizer 在判定語音輸入已結束並完成辨識之前,持續聆聽無法辨識的聲音(babble)的時間。

設定超時值

// Set the initial silence timeout to 6 seconds.
speechRecognizer.Timeouts.InitialSilenceTimeout = TimeSpan.FromSeconds(6.0);

// Set the end silence timeout to 1.2 seconds.
speechRecognizer.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(1.2);

// Set the babble timeout to 0 (infinite — keep listening).
speechRecognizer.Timeouts.BabbleTimeout = TimeSpan.FromSeconds(0);

Note

逾時值會在您開始辨識工作階段之前設定於 SpeechRecognizer 上。 開始一場遊戲後的變更,直到下一場遊戲都不會生效。