2

我正在开发一个新应用程序,我在其中使用 windows phone 8 的语音识别功能。但是,我收到以下异常:

HRESULT 异常:0x800455BC

在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 在 ExcerciseMod7Voice.MainPage.d__4.MoveNext ()

这是我尝试使用的代码:

 private async void btnSpeak_Click(object sender, RoutedEventArgs e)
 {
         var recognizer = new SpeechRecognizerUI();
         recognizer.Settings.ShowConfirmation = true;
         recognizer.Settings.ReadoutEnabled = false;

         try
         {
             var result = await recognizer.RecognizeWithUIAsync();
             if (result.ResultStatus == SpeechRecognitionUIStatus.Succeeded)
             {
                 MessageBox.Show(result.RecognitionResult.Text);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
 }

当我运行应用程序并单击按钮说话时,它会显示消息确认几秒钟然后消失。

注意:我直接在我的手机上测试这个应用程序。(诺基亚 Lumia 920)

4

1 回答 1

3

That error message means that the language isn't supported. I'm not sure what your language settings are but you can get the recognizer with your locale using this (swap en-GB with the culture you want)

var localRec = InstalledSpeechRecognizers.All
                       .Where(r => r.Language == "en-GB").FirstOrDefault();

Then set your recognizer with that language

if(localRec != null)
  recognizer.Recognizer.SetRecognizer(localRec);
else
  MessageBox.Show("Recognizer with the language not found");

If you don't explicitly set the locale above then the system will use the language set in the phone's Speech settings.

于 2013-07-07T12:16:14.150 回答