首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cortana Windows 10 UWP集成-在VCD中使用{*}

Cortana Windows 10 UWP集成-在VCD中使用{*}
EN

Stack Overflow用户
提问于 2016-04-02 16:24:11
回答 2查看 599关注 0票数 1

vcd文件规范中,它说{*}用于匹配任何东西。但是,对于示例命令:

代码语言:javascript
复制
<Command Name="addFoodLog">
      <Example> I had a burger for lunch </Example>
      <!--Recording a drink-->
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] drank [a] {*} with [my] {mealtime} </ListenFor>
      <!--Recording a meal-->
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] ate [a] {*} for [my] {mealtime} </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I'm] having {*} for [my] {mealtime} </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> [I] [just] had [a] {*} for {mealtime} </ListenFor>
      <Feedback> Recording your {mealtime}</Feedback>
      <Navigate />
</Command>

打印此输入的结果将是I drank a ... with my dinner

有什么办法能从课文中得到真正的答案吗?或者这是个错误?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-04-05 22:15:37

如果你使用一个短语主题,那么你会解决你的问题,因为它会增加一个更大的词汇量。

以下是一个例子:

代码语言:javascript
复制
<PhraseTopic Label="food">
  <Subject>Food</Subject>
  <Subject>Drink</Subject>
  <Subject>Meal</Subject>
  <Subject>Food</Subject>
</PhraseTopic>

查看语音命令定义元素和属性以获取更多信息

票数 1
EN

Stack Overflow用户

发布于 2016-06-14 18:36:20

下面是如何获得一个搜索词,而不是从一个值的列表。这是针对HTML/JS的,而不是XAML,但是应该给您一个好主意。

XML

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
    <CommandSet xml:lang="en-us" Name="FNOW_en-us">
        <AppName> YourAppName </AppName>
        <Example> Search books </Example>

        <Command Name="SearchFor">
            <Example> Search for Harry Potter </Example>
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> find book {SearchTerm} </ListenFor>
            <Feedback> Searching books </Feedback>
            <Navigate />
        </Command>

        <PhraseTopic Label="SearchTerm" Scenario="Search"/>
    </CommandSet>
</VoiceCommands>

JavaScript

代码语言:javascript
复制
function handleVoiceCommand(args) {
    var command,
        commandResult,
        commandName = '',
        commandProperties = {};

    if (args.detail && args.detail.detail) {
        command = args.detail.detail[0];

        if (command) {
            commandResult = command.result;

            if (commandResult) {
                if (commandResult.rulePath) {
                    commandName = commandResult.rulePath[0];
                }
                if (commandResult.semanticInterpretation) {
                    commandProperties = commandResult.semanticInterpretation.properties;
                }

                // Act on the different commands.
                // Command Names are defined within VoiceCommands.xml.
                switch(commandName) {
                    case 'SearchFor':
                        console.log('Cortana Command: SearchFor');
                        console.log('Search Term: ' + commandProperties.SearchTerm[0]);
                        break;
                }
            }
        }
    }
}

WinJS.Application.addEventListener('activated', function (args) {
    var appLaunchVoiceCommand;

    appLaunchVoiceCommand = Windows.ApplicationModel.Activation.ActivationKind.voiceCommand || 16;
    if (args.detail.kind === appLaunchVoiceCommand) {
        return handleVoiceCommand(args);
    }
});

WinJS.Application.start();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36375767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档