Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add audio from firebase storage in actions on Google?

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&amp;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 ?

like image 936
Raghav Joshi Avatar asked Jan 02 '18 05:01

Raghav Joshi


People also ask

Can I host my Action files on Firebase Hosting?

See the Firebase Hosting get started guide for more information. If you are an existing Firebase user, you can also easily re-use any assets you have hosted for your mobile or web apps. Check out this sample which uses Firebase Hosting and learn more about how this can be used to host your Action files, by visiting our Firebase Hosting docs.

How do I use Google Cloud Storage with Firebase?

On the server, you can use Google Cloud Storage APIs to access the same files. Firebase SDKs for Cloud Storage perform uploads and downloads regardless of network quality. Uploads and downloads are robust, meaning they restart where they stopped, saving your users time and bandwidth.

How do I integrate firebase with Google Ads?

Using Firebase and Google Ads together Firebase is Google’s app software development kit (SDK) and analytics tool. To import your Firebase conversions to Google Ads, you can either link your Google Analytics 4 property or your Firebase project to Google Ads.

How can Firebase help you accelerate app development?

Tune in to learn how Firebase can help you accelerate app development, release with confidence, and scale with ease. Register Cloud Storage for Firebase allows you to quickly and easily upload files to a Cloud Storage bucket provided and managed by Firebase.


3 Answers

Try escaping the & by replacing& with &amp.

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&amp;token=cdf4d1da-1d1f-42eb-a478-3912275d0f37">
</audio>
text
</speak>
like image 53
matthewayne Avatar answered Oct 20 '22 10:10

matthewayne


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 &amp;

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&amp;token=aabcd430-9d46-45f6-ad21-fdca0895123f"></audio></speak>

enter image description here

I've also tested this as part of a Simple Response setting through Dialogflow, and it works fine.

like image 38
Prisoner Avatar answered Oct 20 '22 10:10

Prisoner


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.

like image 27
William DePalo Avatar answered Oct 20 '22 10:10

William DePalo