【问题标题】:Get any value from Cortana voice command result从 Cortana 语音命令结果中获取任何值
【发布时间】:2015-10-10 16:28:40
【问题描述】:

是否可以从 Cortana 语音命令中读取任何值?

例如,当我说:

“在我的图书馆中搜索 {something}”

我想在我的应用中从 {something} 获取结果。

我找到了如何使用 PhraseList 和 PhraseTopic,但在我的情况下,可以是任何单词,而不是一些声明的项目或一个主题。

【问题讨论】:

标签: win-universal-app cortana


【解决方案1】:

在您的 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);

搜索和我的图书馆之间的一切都将是一切

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-02-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多