Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Phone 8.1语音识别+导航服务问题_C# - Fatal编程技术网

C# Windows Phone 8.1语音识别+导航服务问题

C# Windows Phone 8.1语音识别+导航服务问题,c#,C#,我正在使用语音识别为Windows Phone 8.1开发一个应用程序。 此时,我希望使用语音命令在应用程序中导航。应用程序有一个按钮来激活语音识别 我现在的问题是导航服务。 当我按下按钮时,应用程序会识别我的语音设置,但会在NavigationService中引发异常 在我的设备诺基亚lumia 735中运行应用程序时会发生这种情况。 当我使用emulator 8.1 wvga 4英寸512mb时,应用程序运行良好,导航服务运行良好 这个应用程序是一个学校项目的一部分,所以如果有人能帮助我,我

我正在使用语音识别为Windows Phone 8.1开发一个应用程序。 此时,我希望使用语音命令在应用程序中导航。应用程序有一个按钮来激活语音识别

我现在的问题是导航服务。 当我按下按钮时,应用程序会识别我的语音设置,但会在NavigationService中引发异常

在我的设备诺基亚lumia 735中运行应用程序时会发生这种情况。 当我使用emulator 8.1 wvga 4英寸512mb时,应用程序运行良好,导航服务运行良好

这个应用程序是一个学校项目的一部分,所以如果有人能帮助我,我将非常高兴

这是我此刻的代码:

按钮单击代码:

private async void btSpeak_Click(object sender, RoutedEventArgs e)
        {
            recoWithUI = new SpeechRecognizerUI();


            // Query for a recognizer that recognizes French as spoken in France.
            IEnumerable<SpeechRecognizerInformation> language = from recognizerInfo in InstalledSpeechRecognizers.All
                                                                         where recognizerInfo.Language == "en-US"
                                                                         select recognizerInfo;

            // Set the recognizer to the top entry in the query result.
            recoWithUI.Recognizer.SetRecognizer(language.ElementAt(0));

            // Build a string array, create a grammar from it, and add it to the speech recognizer's grammar set.
            string[] triviaCategories = { "activity tracker", "bmi caculator", "meal calculator", "nutrition chart", "settings" };
            recoWithUI.Recognizer.Grammars.AddGrammarFromList("categories", triviaCategories);

            // Display text to prompt the user's input.
            recoWithUI.Settings.ListenText = "Say an option: ";

            // Display an example of ideal expected input.
            recoWithUI.Settings.ExampleText = "Activity Tracker\n @BMI Calculator\n Meal Calculator\n Nutrition Chart\n Settings";

            // Deactivate the readout of recognized text to the user.
            recoWithUI.Settings.ReadoutEnabled = true;

            // Load the grammar set and start recognition.
            SpeechRecognitionUIResult result = await recoWithUI.RecognizeWithUIAsync();

            //  Handle the caputed voice
            if (!String.IsNullOrWhiteSpace(result.RecognitionResult.Text))
            {
                recoWithUI.Dispose();
                VoiceComandsRecognition(result.RecognitionResult.Text.ToString());
            }
            else
                return;

        }
这是一个例外:

{System.Exception:调用COM组件时返回错误HRESULT E_FAIL。 在MS.Internal.XcpImports.CheckHResultUInt32小时 在MS.Internal.XcpImports.SetValueIManagedPeerBase对象中,DependencyProperty属性,字符串s 在MS.Internal.XcpImports.SetValueIManagedPeerBase doh中,DependencyProperty属性,对象对象obj 在System.Windows.DependencyObject.SetObjectValueToCoreDependencyProperty dp中,对象值 在System.Windows.DependencyObject.SetEffectiveValueDependencyProperty属性、EffectiveValueEntry和newEntry、Object newValue中 在System.Windows.DependencyObject.UpdateEffectiveValueDependencyProperty属性、EffectiveValueEntry oldEntry、EffectiveValueEntry和newEntry、ValueOperation操作中 在System.Windows.DependencyObject.SetValueInternalDependencyProperty dp中,对象值,布尔AlloreAndonlySet 在Microsoft.Phone.Controls.PhoneApplicationFrame.UpdateMarginThickness区域,页面方向 在Microsoft.Phone.Controls.PhoneApplicationFrame.OnVisibleRegionChangeObject发送方,VisibleRegionChangeEventArgs args args 在Microsoft.Phone.Controls.PhoneApplicationFrame.System.Windows.Controls.IFrame.InternalOnVisibleRegionChangeObject发送方,VisibleRegionChangeEventArgs args args 在System.EventHandler1.InvokeObject发送方,TEventArgs e 在System.Windows.Controls.Frame.FireEventHandler[T]EventHandler1处理程序中,对象发送器,T参数 在Microsoft.Phone.Controls.PhoneApplicationPage.set_VisibleRegionInPhysicalPixelRect值中 位于Microsoft.Phone.Controls.PhoneApplicationPage.UpdateCurrentVisualState 位于Microsoft.Phone.Controls.PhoneApplicationFrame.InternalUpdateOrientation和MarginInforPagePhoneApplicationPage visiblePage 在Microsoft.Phone.Controls.PhoneApplicationFrame.System.Windows.Controls.IFrame.InternalUpdateOrientation和MargInformationPageiPhoneApplicationPage visiblePage中 在System.Windows.Navigation.NavigationService.CompleteNavigationDependencyObject内容中,导航模式 在System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_CallbackIAsyncResult结果}


这是Windows Phone中已确认的错误。微软将在他们告诉我的6-12个月内修复它。

什么是例外?@aloisdg我已经更新了quest是例外。你能帮助我吗?谢谢你能开始尝试吗?谢谢你的网址。我一到家就去试试。感谢you@aloisdg这不能解决我的问题。我认为这个问题是由于异步按钮事件造成的。你有参考资料吗,比如连接帖子的链接?我没有找到任何相关信息。你有什么证据吗?我想用计算机语音命令浏览网页。我怎么能做到呢???这可能吗?关于你的问题你有什么消息吗?
public void VoiceComandsRecognition(string CapturedVoice)
        {
            try
            {
                switch (CapturedVoice)
                {
                    case "activity tracker":
                        NavigationService.Navigate(new Uri("/Pages/ActivityTracker.xaml", UriKind.Relative));
                        break;
                    case "bmi calculator":
                        NavigationService.Navigate(new Uri("/Pages/BMIcalculator.xaml", UriKind.Relative));
                        break;
                    case "meal calculator":
                        NavigationService.Navigate(new Uri("/Pages/MealCalculator.xaml", UriKind.Relative));
                        break;
                    case "nutrition chart":
                        NavigationService.Navigate(new Uri("/Pages/NutritionChart.xaml", UriKind.Relative));
                        break;
                    case "settings":
                         NavigationService.Navigate(new Uri("/WinHealth;component/Pages/SettingsPage.xaml", UriKind.RelativeOrAbsolute));
                         break;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Erro ao reconhecer o comando. "+e.ToString());
            }
    }