Reputation: 15
I'm looking for a way to invoke Cortana in an UWP-Application by a button_clicked event. If the button is clicked I want Cortana to listen such as I had activated her with the "Hey Cortana" phrase or manually by clicking the microphone button. I don't want the application to always listen, it should only listen after clicking the defined button.
Are there any solutions?
Upvotes: 1
Views: 151
Reputation: 3923
I am really not sure ultimately what you want to use Speech for. But the Framework Element that you are looking for is Speech Recognition
Take a look at Speech Recognition from MSDN
Below is a sample of recognizing speech with a Listening UI.
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();
}
You can use this without using UI as Below
Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();`
I would strongly Suggest you watch this video from MVA on how to use Speech Recognition in UWP
Upvotes: 1