如何告诉Google的Actions流音频? [英] How can I tell Actions on Google to stream audio?

查看:118
本文介绍了如何告诉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: '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',
  }),
}));

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

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

我发布了一个答案在此处

基本上,您可以创建一个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", "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"]);

这篇关于如何告诉Google的Actions流音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆