从Cortana语音命令结果中获取任何值 [英] Get any value from Cortana voice command result

查看:88
本文介绍了从Cortana语音命令结果中获取任何值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆