如何告诉Google的Actions流音频?

编程入门 行业动态 更新时间:2024-10-07 12:17:18
本文介绍了如何告诉Google的Actions流音频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在编写一个可与​​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流音频?

本文发布于:2023-11-28 08:09:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641605.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:流音   Google   Actions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!