【发布时间】:2015-10-10 16:28:40
【问题描述】:
是否可以从 Cortana 语音命令中读取任何值?
例如,当我说:
“在我的图书馆中搜索 {something}”
我想在我的应用中从 {something} 获取结果。
我找到了如何使用 PhraseList 和 PhraseTopic,但在我的情况下,可以是任何单词,而不是一些声明的项目或一个主题。
【问题讨论】:
是否可以从 Cortana 语音命令中读取任何值?
例如,当我说:
“在我的图书馆中搜索 {something}”
我想在我的应用中从 {something} 获取结果。
我找到了如何使用 PhraseList 和 PhraseTopic,但在我的情况下,可以是任何单词,而不是一些声明的项目或一个主题。
【问题讨论】:
在您的 VoiceCommands.xml 中,您需要:
<PhraseTopic Label="something" Scenario="Natural Language">
<Subject> Natural Language </Subject>
</PhraseTopic>
在您的 App.xaml.cs 中您需要:
private string SemanticInterpretation(string interpretationKey, SpeechRecognitionResult speechRecognitionResult)
{
return speechRecognitionResult.SemanticInterpretation.Properties[interpretationKey].FirstOrDefault();
}
}
在 OnActivated 方法中(或您处理命令的其他任何地方) 你可以读出来:
switch (voiceCommandName)
{
case "something":
string something = this.SemanticInterpretation("something", speechRecognitionResult);
搜索和我的图书馆之间的一切都将是一切
【讨论】: