Cortana没有注册应用程序的语音命令

时间:2015-08-12 22:29:37

标签: windows-runtime windows-10 win-universal-app windows-10-mobile

我正在努力让Cortana与后台应用服务进行互动。 Cortana正在使用一个语音命令集,但是当我尝试来自不同命令集的任何语音命令时,它只是在Bing中打开搜索。

有关可能导致它的原因的任何建议或对命令的更改以使其与Cortana更好地工作?

不起作用的命令集:

<Command Name="SetTemperatureDefault">
  <Example> change the temperature to 72 degrees </Example>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> set [the] temperature to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> change [the] temperature to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> increase [the] temperature to {Temperature} </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> decrease [the] temperature to {Temperature} </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> set to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> change to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> increase to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> decrease to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> set temp to {Temperature} degrees </ListenFor>
  <ListenFor RequireAppName="BeforeOrAfterPhrase"> change temp to {Temperature} degrees </ListenFor>
  <Feedback> Changing temperature... </Feedback>
  <VoiceCommandService Target="CozyVoiceCommandService" />
</Command>

1 个答案:

答案 0 :(得分:1)

首先,保证在应用初始化期间正确安装了VCD。确保它没有给出任何例外。

protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
    ...
    // Install the VCD
    try
    {
        StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"HomeControlCommands.xml");
        await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine("There was an error registering the Voice Command Definitions", ex);
    }
}

然后,当您使用{ Temperature }命令时,您需要在列出所有之后使用 PhraseTopic 命令

    ...
    <Command Name="SetTemperatureDefault">
      <Example> change the temperature to 72 degrees </Example>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> set [the] temperature to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> change [the] temperature to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> increase [the] temperature to {Temperature} </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> decrease [the] temperature to {Temperature} </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> set to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> change to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> increase to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> decrease to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> set temp to {Temperature} degrees </ListenFor>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> change temp to {Temperature} degrees </ListenFor>
      <Feedback> Changing temperature... </Feedback>
      <VoiceCommandService Target="CozyVoiceCommandService" />
    </Command>

    <PhraseTopic Label="Temperature" />
  </CommandSet>
</VoiceCommands>

我在这里测试了它,它就像一个魅力。

这里是前景中Cortana的完整tutorial,可能对您可能需要的其他情况有所帮助。