mig*_*lcv 3 win-universal-app cortana
从Cortana语音命令中读取任何值是否可行?
例如,当我说:
"在我的图书馆中搜索{something}"
我想在我的应用中从{something}获得结果.
我找到了如何使用PhraseList和PhraseTopic,但在我的情况下可以是任何单词而不是一些声明的项目或一个主题.
小智 6
在您的VoiceCommands.xml中,您需要:
<PhraseTopic Label="something" Scenario="Natural Language">
<Subject> Natural Language </Subject>
</PhraseTopic>
Run Code Online (Sandbox Code Playgroud)
在App.xaml.cs中,您需要:
private string SemanticInterpretation(string interpretationKey, SpeechRecognitionResult speechRecognitionResult)
{
return speechRecognitionResult.SemanticInterpretation.Properties[interpretationKey].FirstOrDefault();
}
}
Run Code Online (Sandbox Code Playgroud)
在OnActivated方法中(或者您处理命令的任何其他位置),您可以通过以下方式读出它:
switch (voiceCommandName)
{
case "something":
string something = this.SemanticInterpretation("something", speechRecognitionResult);
Run Code Online (Sandbox Code Playgroud)
搜索和我的库之间的一切都将是一切
| 归档时间: |
|
| 查看次数: |
295 次 |
| 最近记录: |