Google API Text-to-speech

Hi, I’d like to know if it’s possible to implement the Text-to-speech feature from google’s API in bubble

more especifically, using the wave net voice.

I have no experience in coding programming whatsoever, so I’m finding some difficulties.

Thanks, since then

3 Likes

Yes you can using the API Connector.

I’ve tried it, but I couldn’t initialize the call, there was always happening an error

Can you provide a screenshot with the setting?
And what the error was

so the link with the REST doc is:

The API is activated in my Cloud’s Console, but I’m quite lost on how to fill the paremeters

Call are POST and not GET.
https://cloud.google.com/text-to-speech/docs/reference/rest/v1beta1/text/synthesize

1 Like

Then appears this error:

There was an issue setting up your call.

Raw response for the API
Status code 403
{
“error”: {
“code”: 403,
“message”: “The request is missing a valid API key.”,
“status”: “PERMISSION_DENIED”
}
}

Is it wrong the way I put the key?

In google, key doesn’t go in the header but in url parameters. Delete the shared header and use private key in url instead

1 Like

Looks like the key is working in the URL (thx btw) but I’m still not able to Iniciate the call, I don’t know if it’s because it’s needed an OAuth or if it’s because the parameters that are wrong (I’m really lost if this, I don’t understand anything about java or any other coding) I tried to follow the required parameters as the following images:

you will need to add the header
Content-Type with value application/json
And be sure that you match the formatting of the json requested by Google.

2 Likes

@ri_scc_94 were you able to figure this out? I’m interested in using the Google API for their speech-to-text tool (similar set up and documentation I assume) and want to make sure this is capable of being used in Bubble.

I couldn’t, I stop trying because I have some other problems more urgent to solve, but I’m still interested.

I’m crazily noob in this programming/api area haha please tell me if you find out

I’m actually trying to implement this in my app (text-to-speech with Wavenet) at the moment as well. I’m getting the same error response about the missing API key when I actually made an API call from the bubble but was able to initialize the request which is even more strange to me.

Were you able to download the JSON credentials file from google? I believe you want to use JSON web token as the authentication type and place the everything in between -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- in the box that will show up when you select that authentication method.

Google’s format for the key will not work as is, it uses the JSON convention of \n to denote each new line. You will need to actual create a new line every time you see \n in the file and delete the \n before pasting it into the input pox in bubble.

That enabled me to initialize the call. Now I am trying to figure out why I am getting the API key not valid. Please pass a valid API key response error when I actually make a call from the app.

1 Like

Actually, what I described above should work. I had a problem in my app, not the API request which is why I was able to initialize it but it wasn’t working in my app.

My problem now is that the api returns a Base 64 encoded string that represents an audio file that I need to actually convert to an mp3 file in order to get it to play sound. I am not sure how this will work in bubble.

I’m having problems here, but about the format of the file, google has a way to change the format you want, is the variable “audioEncoding”, that can be LINEAR16, MP3 or OGG_OPUS.

Check it out:

{
“audioEncoding”: enum (AudioEncoding),
“speakingRate”: number,
“pitch”: number,
“volumeGainDb”: number,
“sampleRateHertz”: integer,
“effectsProfileId”: [
string
]
}

1 Like

@ryanellman @ri_scc_94 @unscripted.app

Here you go:

I hope it helps.

I have an old app that I started and would sell very cheap if your interested. PM if so, if not, the above should help you get started.

9 Likes

Thanks @realisedgains! I was actually able to get it working and can confirm that the method you have here works.

2 Likes

Which part are you still having problems with, the authentication? I may be able to help you because I was able to get it working.

As far as the file format goes, that is correct that the API allows you to specifiy other file formats, but more work needs to be done in order to actually play the API response. The audio content comes back as base 64 encoded because it is a JSON response and JSON does not support binary data (all of those file formats are intended to take binary data). I assumed this meant I was going to have to decode the data to binary, save it to n mp3 file, and feed the mp3 file to bubble’s audio player but I actually found a much simpler method.

data:[<MIME-type>][;charset=<encoding>][;base64],<data>

This is called a data URI and will save successfully to the database and work as an audio source. The implementation of this for Google Text to Speech could look like this.

data:audio/mp3;base64, Google Text to Speech API Call's - audio content 

Where “Google Text to Speech API Call’s - audio content” is a bubble API call with your parameters returning the base 64 encoded response.

Super simple and saves the trouble of having to do different manipulations of the audio response in javascript, which is something I try and avoid whenever possible for simplicity’s sake.

2 Likes

I’m still having problems into making the call.

I entered the .Json as you said, it still not calling, I have no idea why. I’ve tried with my google email and with the e-mail in the json file, both didn’t work.

As for what you said about the audio encoding base64 to MP3, I didn’t understand where to put it (I don’t know anything about programing haha)

here are the prints:



If you could help me, I would be the most grateful!

Double check your JSON. It looks like you have an equals sign instead of a colon after text.

3 Likes