gpt4 book ai didi

actions-on-google - 如何告诉 Actions on Google 流式传输音频?

转载 作者:行者123 更新时间:2023-12-03 23:50:44 25 4
gpt4 key购买 nike

我正在编写一个与 Google Actions 一起使用的应用程序。唯一令人遗憾的是,我找不到任何关于如何形成我的响应的信息,以便 Google 从给定的 URL 流式传输音频。谷歌甚至支持这个吗?

我已经在 Alexa 上编写了相同的应用程序,在 Alexa 上你所要做的就是返回一个音频项目( token 、URL、播放命令),Alexa 将开始流式传输它。

我应该提到我没有使用 API.AI,而只是使用 Actions SDK 并使用 C# 在 Asure 上托管我的 Web 服务。

所以,最重要的是...如何通过 Actions SDK 格式化响应以将 MP3 文件流式传输到 Google Home?

最佳答案

更新:第一个答案仅适用于 Dialogflow 的 V1。对于 V2,您可以通过这种方式创建 mediaResponse(来自 Google 的文档):

conv.ask(new MediaObject({
name: 'Jazz in Paris',
url: 'http://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
description: 'A funky Jazz tune',
icon: new Image({
url: 'http://storage.googleapis.com/automotive-media/album_art.jpg',
alt: 'Media icon',
}),
}));

================================================== ======================

我发布了一个答案 over here .

基本上,您可以创建一个 mediaResponse 对象来播放您的音频文件。我可以播放 50 分钟的音频文件就好了。

Node.js 中的代码示例可以是(使用当前文档):
const richResponse = app.buildRichResponse()
.addSimpleResponse("Here's song one.")
.addMediaResponse(app.buildMediaResponse()
.addMediaObjects([
app.buildMediaObject("Song One", "https://....mp3")
.setDescription("Song One with description and large image.") // Optional
.setImage("https://....jpg", app.Media.ImageType.LARGE)
// Optional. Use app.Media.ImageType.ICON if displaying icon.
])
)
.addSuggestions(["other songs"]);

关于actions-on-google - 如何告诉 Actions on Google 流式传输音频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42048385/

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