从Cortana语音命令结果中获取任何值 [英] Get any value from Cortana voice command result
问题描述
可以从Cortana语音命令中读取任何值吗?
Is it posible to read any value from Cortana voice command?
例如,当我说:
在我的图书馆中搜索{something}
"Search {something} in my library"
我想从{something }。
I want to get the result from {something} in my app.
我找到了如何使用 PhraseList 和 PhraseTopic 的方法,但是在我的情况下
I found how to work with PhraseList and PhraseTopic, but in my case could be any word instead of some declared items or one topic.
推荐答案
在VoiceCommands.xml中,您需要:
In your VoiceCommands.xml you need:
<PhraseTopic Label="something" Scenario="Natural Language">
<Subject> Natural Language </Subject>
</PhraseTopic>
在您的App.xaml.cs中,您需要:
In your App.xaml.cs you need:
private string SemanticInterpretation(string interpretationKey, SpeechRecognitionResult speechRecognitionResult)
{
return speechRecognitionResult.SemanticInterpretation.Properties[interpretationKey].FirstOrDefault();
}
}
在OnActivated方法中(或在其他地方处理)命令)
您可以使用以下命令读出它:
In the OnActivated Method (or wherever else you Handle the command) you can read it out with:
switch (voiceCommandName)
{
case "something":
string something = this.SemanticInterpretation("something", speechRecognitionResult);
从搜索到我的图书馆之间一切都是
something will be everything between search and in my library
这篇关于从Cortana语音命令结果中获取任何值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!