How can I report Actions to Google for streaming audio?

I am writing an application for working with Google Actions. The only flaw is that I cannot find any information on how to form my answer so that Google transmits audio from the given URL. Does Google still support this?

I already wrote the same application on Alexa, and on Alexa all you have to do is return the sound element (token, URL, play command), and Alexa will start transferring it.

I should mention that I DO NOT use the API.AI, but just use the Actions SDK and host my web service on Asure using C #.

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

+13
audio-streaming actions-on-google google-home
source share
2 answers

UPDATE: The first answer only works with V1 Dialogflow. As for V2, you can create mediaResponse as follows (from Google 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 the answer here .

In essence, you can create a mediaResponse object that will play your audio file. I can play an audio file in 50 minutes.

Sample code in Node.js could be (with current documentation):

 const richResponse = app.buildRichResponse() .addSimpleResponse("Here 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"]); 
+5
source share

According to the documentation, you can embed elements in SSML. https://developers.google.com/actions/reference/ssml contains the following example:

 <speak> Here are <say-as interpet-as="characters">SSML</say-as> samples. I can pause <break time="3s"/>. I can play a sound <audio src="https://www.example.com/MY_MP3_FILE.mp3">didn't get your MP3 audio file</audio>. I can speak in cardinals. Your number is <say-as interpret-as="cardinal">10</say-as>. Or I can speak in ordinals. You are <say-as interpret-as="ordinal">10</say-as> in line. Or I can even speak in digits. The digits for ten are <say-as interpret-as="characters">10</say-as>. I can also substitute phrases, like the <sub alias="World Wide Web Consortium">W3C</sub>. Finally, I can speak a paragraph with two sentences. <p><s>This is sentence one.</s><s>This is sentence two.</s></p> </speak> 

EDIT

p / s: SSML in Documents has the following limitations:

  • One channel is preferred, but stereo is acceptable.
  • The maximum duration is 120 seconds. If you want to play longer audio, consider implementing a media response. The file size limit is 5 megabytes.

  • The source URL must use the HTTPS protocol.

  • Our UserAgent when extracting audio "Google-Speech-Actions".
+5
source share