以编程方式激活C#Cortana语音

时间:2015-02-08 19:05:59

标签: c# windows-phone-8.1 cortana

我试图以编程方式调用Cortana。

我已经在使用此代码启动Cortana

await Launcher.LaunchUriAsync(new Uri("bing://home"));

问题是,为了进行搜索,您必须单击Cortana中的麦克风按钮。

我想要的是,当Cortana启动时,不应该让用户按下麦克风按钮进行搜索。就像Cortana在我想要的时候或者至少在它打开时开始听。

这可能吗?如果是,那怎么样?

2 个答案:

答案 0 :(得分:3)

由于app开发人员可以随意开始记录用户所说的内容,因此隐私问题非常不可能。

答案 1 :(得分: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

考虑使用Cortana在前台集成您的应用程序。看看here