【问题标题】:Windows Cortana always listen from inside appWindows Cortana 始终从应用程序内部收听
【发布时间】:2015-03-25 15:20:58
【问题描述】:

windows cortana 的新更新具有始终监听模式,类似于 Google 的“OK Google”命令,即使手机处于待机状态,用户也可以激活 Cortana。是“嘿 Cortana”。

以同样的方式,当我的应用程序启动时,我希望有一个始终监听模式,它可以只监听特定的单词集(就像“嘿 Cortana”),并相应地响应它。

【问题讨论】:

    标签: windows-phone-8 cortana


    【解决方案1】:

    您可以使用适用于 Windows 10 的 ContinuousRecognitionSession 实现连续听写。

    private SpeechRecognizer speechRecognizer;
    private CoreDispatcher dispatcher;
    private StringBuilder dictatedTextBuilder;
    
    this.dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
    this.speechRecognizer = new SpeechRecognizer();
    SpeechRecognitionCompilationResult result =
    
    await speechRecognizer.CompileConstraintsAsync();
    speechRecognizer.ContinuousRecognitionSession.ResultGenerated +=
    ContinuousRecognitionSession_ResultGenerated;
    
    private async void ContinuousRecognitionSession_ResultGenerated(
    SpeechContinuousRecognitionSession sender,
    SpeechContinuousRecognitionResultGeneratedEventArgs args)
    {
    
    if (args.Result.Confidence == SpeechRecognitionConfidence.Medium ||
      args.Result.Confidence == SpeechRecognitionConfidence.High)
      {
        dictatedTextBuilder.Append(args.Result.Text + " ");
    
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
          dictationTextBox.Text = dictatedTextBuilder.ToString();
          btnClearText.IsEnabled = true;
        });
      }
    else
    {
      await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
          dictationTextBox.Text = dictatedTextBuilder.ToString();
        });
    }
    }
    

    这里是完整的example

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2016-02-22
      • 2016-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多