【问题标题】:C# UWP SpeechRecognizer problemsC# UWP SpeechRecognizer 问题
【发布时间】:2015-11-27 22:38:50
【问题描述】:

我正在开发 UWP 并想使用 SpeechRecognizer。它应该只对单词“Next”和“Back”做出反应。但通常,它会将“NExt”识别为“Back”。我的代码如下。如何解决?

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();
        }

这里是 ResultGeneratedEvent:

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;
                }
            });
        }

【问题讨论】:

    标签: c# speech-recognition uwp


    【解决方案1】:

    不幸的是,您在使用语音识别方面遇到了困难,有时它无法准确识别您所说的内容。

    我推荐的一件事是利用 Confidence level 作为结果的一部分。使用置信度,您可以决定是要接受结果还是尝试要求用户重复他们所说的话。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 2017-07-20
      • 2019-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多