Windows 8 中的语音识别器中出现错误
本文关键字:错误 语音识别 Windows | 更新日期: 2023-09-27 18:35:53
我想将语音识别与我的应用程序集成。
我可以使用语音识别器UI执行此操作,但是当我使用语音识别器创建自己的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");
}
}
顺便说一句,看起来您没有使用 SpeechRecognizer.SetRecognizer
设置识别器。 我假设你想要听写结果;否则,您还需要设置语法。