Cortana 未注册应用程序的语音命令
Cortana not registering app's voice command
我正在努力让 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>
首先保证你的VCD在app初始化时已经正确安装。确保它没有给出任何异常。
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.
之后
...
<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,在您可能需要的其他情况下可能会有所帮助。
我正在努力让 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>
首先保证你的VCD在app初始化时已经正确安装。确保它没有给出任何异常。
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.
之后 ...
<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,在您可能需要的其他情况下可能会有所帮助。