0
我想將語音識別與我的應用程序集成在一起。Windows 8語音識別器中的錯誤
我可以用SpeechRecognizerUI做到這一點,但是當我用SpeechRecognizer創建自己的UI時,它會產生一個異常?爲什麼如此.. 此代碼總是生成一個異常並顯示「引發異常」。
我不想使用SpeechRecognizerUI。
private async void Button_Click(object sender, RoutedEventArgs e)
{
SpeechRecognizer speechrecognizer = new SpeechRecognizer();
try
{
SpeechRecognitionResult result = await speechrecognizer.RecognizeAsync();
if (result.TextConfidence != SpeechRecognitionConfidence.Rejected)
{
txt.Text = result.Text;
}
}
catch (Exception err)
{
int privacyPolicyHResult = unchecked((int)0x80045509);
if (err.HResult == privacyPolicyHResult)
{
MessageBox.Show("You will need to accept the speech privacy policy in order to use speech recognition in this app.");
}
else
{
MessageBox.Show("Exception Raised");
}
}
err.HResult的值會很有趣。如果你有它,也許這個解決方案是微不足道的,或者這個例外本身可以爲你提供一些明確的信息。 – Stefan