我期待着让 Cortana 将自定义命令重定向到我的应用程序(Cortana API 集成)。
命令.xml
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" >
<CommandPrefix>Computer</CommandPrefix>
<Example> who are the indians </Example>
<Command Name="Origins">
<Example> who are the indians </Example>
<ListenFor> who are the {tribe} </ListenFor>
<Feedback> looking for {tribe} </Feedback>
<Navigate/>
</Command>
<PhraseTopic Label="tribe" Scenario="Tribe Info">
<Subject> Tribe </Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
App.xaml.cs 的提取物
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
try
{
var storageFile =
await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appx:///Commands.xml"));
await Windows.Media.SpeechRecognition.VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(storageFile);
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("Failed");
MessageDialog msg = new MessageDialog("Problem chief.");
msg.ShowAsync();
//throw;
}
}
我还在清单文件中打开了麦克风功能。我正在运行 VS 2015,并将其直接调试到运行 Windows 8.1 的设备 lumia 525 上。该应用程序安装正常(由于我没有添加任何 UI 部分,它显示一个简单的黑屏)不会崩溃,并且调试不会显示任何异常。
'App6.exe' (CoreCLR: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'App6.exe' (CoreCLR: .): Loaded 'D:\WPSystem\APPREPOSITORY\d8c976b1-9b9b-47a3-8b2c-8f6dc74eeee5_1.0.0.0_neutral__2f5008nxamf4t\NI\App6.ni.EXE'. Symbols loaded.
'App6.exe' (CoreCLR: .): Loaded 'C:\windows\system32\WinMetadata\Windows.winmd'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'App6.exe' (CoreCLR: .): Loaded 'C:\windows\system32\System.Runtime.WindowsRuntime.NI.DLL'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'App6.exe' (CoreCLR: .): Loaded 'C:\windows\system32\SYSTEM.NI.DLL'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'App6.exe' (CoreCLR: .): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
The thread 0xf44 has exited with code 0 (0x0).
Cortana 在“我能说什么?”中没有我的命令。list 也不响应命令。