【问题标题】:Error In Speech Recognizer in Windows 8Windows 8 中的语音识别器错误
【发布时间】:2013-10-17 20:15:43
【问题描述】:

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

我可以使用 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 的值会很有趣。如果你有它,也许解决方案是微不足道的,或者异常本身可能为你提供了一些明确的信息。

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多