Using Google Cloud Text-to-Speech API using Postman/Windows

Prerequisites

Make sure the billing method is active and enabled on the Google Cloud Console. (Pro Tip: Set  a Budget in “Budgets & alerts” to keep track of expenses within a Google Cloud account. You can set alerts to notify billing admins and users when a budget goes over a specified amount.)
Enable “Cloud Text-to-Speech API” on Google Cloud APIs & Services https://console.cloud.google.com/apis/dashboard
API Key Generated from “Credentials section” on APIs & Services. (Restrict access to prevent unauthorized use. Key can be programmed to set restrictions on select APIs or applications.)

Request URL:

https://texttospeech.googleapis.com/v1/text:synthesize?key=kMgU4BoTkDg-cpWjJSkZbJzKvpgKNbfDPUpzvxi (Generated from the Prerequisites above)

Request Body:

{
“input”:{
“text”:”This is where the Text goes”
},
“voice”:{
“languageCode”:”en-us”,
“name”:”en-US-Neural2-G”,
“ssmlGender”:”FEMALE”
},
“audioConfig”:{
“audioEncoding”:”MP3″
}
}

Copy Everything with “audioContent” jSON, save the encoded data as a text file.

Use certutil in Windows to decode it to mp3 file

certutil -decode textfile.txt audiofile.mp3

Supported Voice & Languages

https://cloud.google.com/text-to-speech/docs/voices

Additional Reference

https://cloud.google.com/text-to-speech/docs/reference/rest/?apix=true

Leave a Reply