[英]voice command to capture photo
I use Windows.Media.Capture.MediaCapture
in my Windows Phone 8.1 app to capture a photo. 我在Windows Phone 8.1应用程序中使用Windows.Media.Capture.MediaCapture
捕获照片。 Instead of a button, I'd like to trigger the photo capturing process by a voice command (for example, if the user says 'cheese'). 我想通过语音命令(例如,如果用户说“奶酪”)来触发照片捕获过程,而不是按钮。 How can I detect such a voice command? 如何检测到这样的语音命令?
You can use the SpeechRecognizer class . 您可以使用SpeechRecognizer类 。
Here's a sample from MSDN : 这是MSDN的示例:
private async void StartRecognizing_Click(object sender, RoutedEventArgs e)
{
// Create an instance of SpeechRecognizer.
var speechRecognizer = new Windows.Media.SpeechRecognition.SpeechRecognizer();
// Compile the dictation grammar by default.
await speechRecognizer.CompileConstraintsAsync();
// Start recognition.
Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();
// Do something with the recognition result.
var messageDialog = new Windows.UI.Popups.MessageDialog(speechRecognitionResult.Text, "Text spoken");
await messageDialog.ShowAsync();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.