在UWP-Application中单击按钮调用Cortana

时间:2016-10-17 12:46:55

标签: uwp cortana

我正在寻找一种通过button_clicked事件在UWP-Application中调用Cortana的方法。如果单击该按钮,我想让Cortana听,例如我用“Hey Cortana”短语激活她,或者通过单击麦克风按钮手动激活她。我不希望应用程序始终监听,只应在单击定义的按钮后进行监听。

有没有解决方案?

1 个答案:

答案 0 :(得分:0)

我真的不确定你最终想要使用Speech for。但您正在寻找的框架元素是Speech Recognition

查看Speech Recognition from MSDN

以下是使用倾听用户界面识别语音的示例。

private async void StartRecognizing_Click(object sender, RoutedEventArgs e)
{
    speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer();
    await speechRecognizer.CompileConstraintsAsync();
    Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();
    var messageDialog = new Windows.UI.Popups.MessageDialog(speechRecognitionResult.Text, "Text spoken");
    await messageDialog.ShowAsync();
}

您可以在不使用UI的情况下使用此功能

Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();`

我强烈建议您在how to use Speech Recognition in UWP

上观看MVA上的这段视频