Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.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#UWP语音识别器问题_C#_Speech Recognition_Uwp - Fatal编程技术网

C#UWP语音识别器问题

C#UWP语音识别器问题,c#,speech-recognition,uwp,C#,Speech Recognition,Uwp,我正在开发UWP,希望使用语音识别器。它应该只对“下一步”和“上一步”作出反应。但通常,它会将“下一步”识别为“返回”。我的代码如下。如何解决这个问题 var defaultLanguage = SpeechRecognizer.SystemSpeechLanguage; _speechRecognizer = new SpeechRecognizer(defaultLanguage); _coreDispatcher = CoreWindow.GetForCur

我正在开发UWP,希望使用语音识别器。它应该只对“下一步”和“上一步”作出反应。但通常,它会将“下一步”识别为“返回”。我的代码如下。如何解决这个问题

var defaultLanguage = SpeechRecognizer.SystemSpeechLanguage;
        _speechRecognizer = new SpeechRecognizer(defaultLanguage);
        _coreDispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
        var constraintList = new SpeechRecognitionListConstraint(new List<string>() { "Next", "Back" });
        _speechRecognizer.Constraints.Add(constraintList);

        var result = await _speechRecognizer.CompileConstraintsAsync();
        if (result.Status == SpeechRecognitionResultStatus.Success)
        {
            _speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated;
            _speechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed;
            await _speechRecognizer.ContinuousRecognitionSession.StartAsync();
        }

不幸的是,你在语音识别方面遇到了困难,有时它无法准确识别你所说的话

我推荐的一件事是利用你们得到的结果。通过自信,你可以决定是接受结果还是尝试让用户重复他们所说的

private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args)
    {
        {
            await _coreDispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {

                string command = args.Result.Text;
                Messenger.Default.Send(new VoiceReactMessage(command));
                switch (command)
                {
                    case "Next":
                        SetHorizontalOffset(-ItemsPanelRoot.ActualWidth);
                        break;
                    case "Back":
                        SetHorizontalOffset(ItemsPanelRoot.ActualWidth);
                        break;
                }
            });
        }