我将Cortana集成到我的应用程序(UWP和Winjs),但是当我试图安装VCD文件时,我得到了这个错误:
Status is 'error', but getResults did not return an errormain.js (代码包装在应用程序的激活处理程序事件上):
wap.current.installedLocation.getFileAsync("Commands.xml").then(function (file) {
return voiceCommandManager.installCommandDefinitionsFromStorageFileAsync(file);
}, function (er) {
console.error('error file Commands.xml', er);
}).then(function () {
var language = window.navigator.userLanguage || window.navigator.language;
var commandSetName = "BibleCommandSet_" + language.toLowerCase();
if (voiceCommandManager.installedCommandDefinitions.hasKey(commandSetName)) {
var vcd = voiceCommandManager.installedCommandDefinitions.lookup(commandSetName);
} else {
console.log('VCD not installed yet?');
}
}, function (ee) {
console.error("installCommandDefinitionsFromStorageFileAsync error", ee);
});Commands.xml:
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
<CommandSet xml:lang="en-us" Name="BibleCommandSet_en-us">
<AppName> Bible </AppName>
<Example> Go to genesis 1,9 </Example>
<Command Name="goToQuote">
<Example> Go to genesis 1,9 </Example>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}</ListenFor>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}{number}</ListenFor>
...
<ListenFor RequireAppName="BeforeOrAfterPhrase"> open {book} {number}{number},{number}{number}</ListenFor>
<Feedback> Ok i'm opening {book} </Feedback>
<Navigate/>
</Command>
</CommandSet>修复:在文件的另一行中,我有另一个commandSet,我确实调用了一个PhraseList“图书”,但真名是“图书”
发布于 2016-12-28 06:59:24
我将Cortana集成到我的应用程序(UWP和Winjs),但是当我试图安装VCD文件时,我得到了一个错误:状态是‘错误’,但是getResults没有返回一个错误
这是因为您的VCD文件- Command.xml有问题。由于错误是由VCD文件发生的,而不是代码本身,所以您没有获得错误的详细信息。
VCD文件中的特殊字符{}包含要引用的PhraseList或PhraseTopic的Label属性值。在ListenFor或反馈元素中使用。反馈元素中的PhraseList或PhraseTopic引用必须与同一命令中的ListenFor元素中的相应引用匹配。
虽然PhraseList或PhraseTopic是CommandSet的可选子级,但是您在VCD文件中为ListenFor和反馈元素定义了{book}和{name},它们需要相应的PhraseList和Label属性值为name/book。
我基于您更新了VCD文件,现在代码可以成功运行。
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
<CommandSet xml:lang="en-us" Name="BibleCommandSet_en-us">
<AppName> Bible </AppName>
<Example> Go to genesis 1,9 </Example>
<Command Name="goToQuote">
<Example> Go to genesis 1,9 </Example>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book}</ListenFor>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}{number}</ListenFor>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> open {book} {number}{number},{number}{number}</ListenFor>
<Feedback> Ok i'm opening {book} </Feedback>
<Navigate/>
</Command>
<PhraseList Label="book">
<Item>London</Item>
<Item>Las Vegas</Item>
<Item>Melbourne</Item>
<Item>Yosemite National Park</Item>
</PhraseList>
<PhraseList Label="number">
<Item>2</Item>
<Item>3</Item>
<Item>4</Item>
<Item>5</Item>
</PhraseList>
</CommandSet>
</VoiceCommands>更多有关VCD文件的详细信息请参考本文件。
https://stackoverflow.com/questions/41290089
复制相似问题