Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell Actions on Google to stream audio?

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?

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.

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#.

So, bottom line... How can I format a response via the Actions SDK to stream an MP3 file to Google Home?

like image 966
Jay Avatar asked Feb 05 '17 03:02

Jay


1 Answers

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',
  }),
}));

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

I posted an answer over here.

Basically you can create a mediaResponse object that will play your audio file. I can play a 50 mins audio file just fine.

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"]);
like image 72
Rémi C. Avatar answered Nov 06 '22 23:11

Rémi C.