是否可以从 Cortana 语音命令中读取任何值?
例如,当我说:
"Search {something} in my library"
我想从我的应用中的 {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);
某些东西将是搜索和我的图书馆之间的一切
关于win-universal-app - 从 Cortana 语音命令结果中获取任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33056223/