How can I tell Actions on Google to stream audio?
According to the documentation you can embed elements in SSML. https://developers.google.com/actions/reference/ssml includes 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 these limitations :
- Single channel is preferred, but stereo is acceptable.
120 seconds maximum duration. If you want to play audio with a longer duration, consider implementing a media response. 5 megabyte file size limit.
Source URL must use HTTPS protocol.
- Our UserAgent when fetching the audio is "Google-Speech-Actions".
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"]);