我正在尝试通过为我的应用程序工作的 Cortana 让用户与后台应用程序进行交互。
每当我执行 RequestDisambiguationAsync(response) 时,Cortana 都会说它遇到了错误。但是,它不会在 Visual Studio 中的任何地方中断。
关于可能导致它的原因有什么想法吗?下面是我正在使用的代码:
var userPrompt = new VoiceCommandUserMessage();
string home1 = data.Structures[0].Name;
string home2 = data.Structures[1].Name;
userPrompt.DisplayMessage = "Which one did you want to set to home?";
userPrompt.SpokenMessage = String.Format("Which one did you want to set to home? {0} or {1}?", home1, home2);
var userReprompt = new VoiceCommandUserMessage();
userReprompt.DisplayMessage = "Which one did you want to set to home?";
userReprompt.SpokenMessage = "Which one did you want to set to home?";
var structuresContentTiles = new List<VoiceCommandContentTile>();
var structureTile = new VoiceCommandContentTile();
structureTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
structureTile.Title = home1;
structureTile.AppContext = data.Structures[0].Structure_id;
structuresContentTiles.Add(structureTile);
var structureTile2 = new VoiceCommandContentTile();
structureTile2.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
structureTile2.Title = home2;
structureTile.AppContext = data.Structures[1].Structure_id;
structuresContentTiles.Add(structureTile2);
var response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt, structuresContentTiles);
var voiceCommandDisambiguationResult = await voiceServiceConnection.RequestDisambiguationAsync(response);
最佳答案
在某些情况下,当您使用时可能会发生此行为
structureTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
但不提供图像。将其更改为 VoiceCommandContentTileType.TitleOnly,或者如果您提供的是 Line1,请使用 VoiceCommandContentTileType.TitleWithText,或提供图像,这应该会阻止失败的发生。
关于c# - Cortana RequestDisambiguationAsync 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31954679/