1

我正在努力让 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>
4

1 回答 1

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 } 用于命令时,您需要在列出所有Command后使用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 的完整教程,在您可能需要的其他情况下可能会有所帮助。

于 2015-08-14T14:25:06.477 回答