Windows 8中的语音识别器出错

时间:2013-10-17 20:15:43

标签: c# windows windows-phone speech speech-to-text

我想将语音识别与我的应用程序集成。

我能用SpeechRecognizerUI做到这一点但是当我用SpeechRecognizer创建自己的UI时会产生异常吗?为什么这样.. 此代码始终生成异常并显示“Exception Raised”。

我不想使用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");
            }

        }

1 个答案:

答案 0 :(得分:0)

此外,您似乎没有使用SpeechRecognizer.SetRecognizer设置识别器。我假设你想要听写结果;否则你也需要设置语法。