在uwp奇怪行为中的cortana SetPhraseListAsync

时间:2016-05-04 13:35:56

标签: c# win-universal-app cortana

我试图在UWP应用程序中以编程方式更新actselist,我遵循了cortana uwp示例,此代码无效:

   VoiceCommandDefinition commandDefinitions;

                    if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("xxxCommandSet_en-us", out commandDefinitions))
                    {

                            System.Diagnostics.Debug.WriteLine("favouriteStringList not null ");
                            await commandDefinitions.SetPhraseListAsync("favourite", favouritesList);
}

当我尝试使用Windows Phone 8时,它可以正常工作

  Windows.Media.SpeechRecognition.VoiceCommandSet commandSetEnUs;

                if (Windows.Media.SpeechRecognition.VoiceCommandManager.InstalledCommandSets.TryGetValue("xxxCommandSet_en-us", out commandSetEnUs))
                {
                    await commandSetEnUs.SetPhraseListAsync(
                      "favourite", favouritesList);
                }

这里有我的VCD文件

<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
  <CommandSet xml:lang="en-us" Name="xxxCommandSet_en-us">

    <AppName> xxx </AppName>
    <Example> Book a yyy in my favourite home </Example>

    <Command Name="bookyyyInFavourite">
      <Example> Book a yyy in my favourite home </Example> <!--Book xxx a yyy in my favourite home-->
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> book [me] a yyy in my favourite {favourite} </ListenFor>
      <ListenFor RequireAppName="ExplicitlySpecified"> book [me] {builtin:AppName} a yyy in my favourite {favourite} </ListenFor>
      <Feedback> Booking a yyy in my favourite {favourite} </Feedback>
      <Navigate />
    </Command>

    <PhraseList Label="favourite">
      <Item>home</Item>
      <Item>work</Item>
    </PhraseList>

  </CommandSet>

</VoiceCommands>

你知道为什么会这样吗? 感谢

0 个答案:

没有答案