gpt4 book ai didi

c# - Cortana 回复而不是应用程序启动

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:27 25 4
gpt4 key购买 nike

好的,我有一个支持 Cortana 的应用程序。我有一些命令可以导航到特定页面。但在某些情况下,我只想提供回复(文本或由 Cortana 发音)而不是启动整个应用程序。有什么办法吗?

例如,当您问 Cortana “美国的首都是哪里?” 时,她只会回答您“华盛顿”。我想做这样的事情。

最佳答案

看看这个 tutorial 的底部,它详细说明了如何设置她所说和显示的内容。

基本上,您需要有一个根据语音命令运行的后台任务,然后在执行期间您需要创建一个 VoiceCommandUserMessage

使用 taskInstance.TriggerDetails 获取 VoiceServiceConnection

    voiceServiceConnection = 
VoiceCommandServiceConnection.FromAppServiceTriggerDetails(
triggerDetails);

等待语音命令完成

    VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync();

然后添加

VoiceCommandUserMessage userMessage = new VoiceCommandUserMessage();
userMessage.DisplayMessage = "Here’s your trip.";
userMessage.SpokenMessage = "Your trip to Vegas is on August 3rd.";

将其包装在响应中

var response = 
VoiceCommandResponse.CreateResponse(
userMessage);

最后,让 Cortana 显示它:

await voiceServiceConnection.ReportSuccessAsync(response);

另请查看 design guidelines for cortana

关于c# - Cortana 回复而不是应用程序启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31146919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com