问题
To be very clear I want to know how to add audio from firebase storage in actions on Google? I've been stuck in this question since few weeks. I've uploaded my audio in the firebase storage and from it I have copied the link provided by Firebase and and pasted the audio's URL in the given format in speech output. Check how I did:-
<speak>
<audio src="https://firebasestorage.googleapis.com/v0/b/enrich-58fdf.appspot.com/o/xxx.mp3?alt=media&token=aabcd430-9d46-45f6-ad21-fdca0895123f">
</audio>
</speak>
But this didn't work. But few months ago in the Google+ community, I found a guy who asked the question similar to this and Allen Firstenberg replied and he said to add *amp;*token between & and token. So after this, a new code generates i.e.
<speak>
<audio src="https://firebasestorage.googleapis.com/v0/b/enrich-58fdf.appspot.com/o/xxx.mp3?alt=media&token=aabcd430-9d46-45f6-ad21-fdca0895123f">
</audio>
</speak>
But this also didn't work. I think after some tweaks in SSML, this code might have changed or the format is different, which I am not aware of. So can anyone help me out ?
回答1:
Try escaping the &
by replacing&
with &
.
If you're still having trouble try adding some text between the </audio>
tag and the </speak>
tag. Actions on Google requires that both display text and SSML or SSML to be able to be visually represented. Adding text in the SSML will allow your SSML to be rendered visually as well as audibly.
Below is a fulling working SSML string using Firebase storage using both the above mentioned techniques:
<speak>
<audio src="https://firebasestorage.googleapis.com/v0/b/repeater-96d05.appspot.com/o/digital_watch_alarm_long.ogg?alt=media&token=cdf4d1da-1d1f-42eb-a478-3912275d0f37">
</audio>
text
</speak>
回答2:
As both you and @matthewayne noted (and as I noted in a different answer you reference), you need to escape the &
to use proper XML formatting, so it needs to be &
However - I don't see a problem. I used this exact code in the Dialogflow "Text Response" area, and it works without problems:
<speak><audio src="https://firebasestorage.googleapis.com/v0/b/enrich-58fdf.appspot.com/o/welcome.mp3?alt=media&token=aabcd430-9d46-45f6-ad21-fdca0895123f"></audio></speak>
I've also tested this as part of a Simple Response setting through Dialogflow, and it works fine.
回答3:
FWIW: Are you sure that your audio files have been recorded with an acceptable format? I had to use a tool called Audacity to convert some audio clips I had to one of the formats acceptable to the AoG platform:
Format: MP3 (MPEG v2) 24K samples per second 24K ~ 96K bits per second, fixed rate
Format: Opus in Ogg 24K samples per second (super-wideband) 24K - 96K bits per second, fixed rate
Format (deprecated): WAV (RIFF) PCM 16-bit signed, little endian 24K samples per second
For all formats: Single channel is preferred, but stereo is acceptable. 120 seconds maximum duration. 5 megabyte file size limit. Source URL must use HTTPS protocol.
来源:https://stackoverflow.com/questions/48055919/how-to-add-audio-from-firebase-storage-in-actions-on-google