我正在编写一个可与Google Actions一起使用的应用程序。唯一可惜的是,我找不到有关如何形成回复的任何信息,这样Google才能从给定的URL流音频。 Google甚至还支持此功能吗?
I am writing an app to work with Google Actions. The only bummer is that I can't find any information about how to form my response so that Google will stream audio from a given URL. Does Google even support this yet?
我已经在Alexa上编写了相同的应用程序,而在Alexa上,您要做的就是返回音频项目(令牌,URL,播放命令),Alexa将开始流式传输。
I have written the same app on Alexa already, and on Alexa all you have to do is Return an audio item (token, URL, play command) and Alexa will start streaming it.
我应该提到我不是在使用API.AI,而是在使用Actions SDK并托管我的Web服务
I should mention that I am NOT using API.AI, but am simply using the Actions SDK and am hosting my web service on Asure using C#.
那么,底线...如何通过Actions SDK格式化响应以将MP3文件流式传输到Google Home?
So, bottom line... How can I format a response via the Actions SDK to stream an MP3 file to Google Home?
推荐答案更新:第一个答案仅适用于Dialogflow V1。对于V2,您可以通过以下方式(通过Google的文档)创建mediaResponse:
UPDATE: The first answer works only with the V1 of Dialogflow. As for the V2, you can create the mediaResponse this way (from Google's doc):
conv.ask(new MediaObject({ name: 'Jazz in Paris', url: 'storage.googleapis/automotive-media/Jazz_In_Paris.mp3', description: 'A funky Jazz tune', icon: new Image({ url: 'storage.googleapis/automotive-media/album_art.jpg', alt: 'Media icon', }), }));===================== ================================================== =
========================================================================
我发布了一个答案在此处。
基本上,您可以创建一个mediaResponse对象,该对象将播放音频文件。我可以播放50分钟的音频文件。
Basically you can create a mediaResponse object that will play your audio file. I can play a 50 mins audio file just fine.
Node.js中的代码示例可能是(使用当前文档):
A code example in Node.js could be (with the current documentation):
const richResponse = app.buildRichResponse() .addSimpleResponse("Here's song one.") .addMediaResponse(app.buildMediaResponse() .addMediaObjects([ app.buildMediaObject("Song One", "....mp3") .setDescription("Song One with description and large image.") // Optional .setImage("....jpg", app.Media.ImageType.LARGE) // Optional. Use app.Media.ImageType.ICON if displaying icon. ]) ) .addSuggestions(["other songs"]);更多推荐
如何告诉Google的Actions流音频?
发布评论