Search code examples
restgoogle-authenticationgoogle-text-to-speech

Google Cloud Text To Speech REST API Authentication


So I want to use the Google Cloud Text to Speech using a simple POST request from my C++ program, the problem is with their authentication. I did create a service account as they mentioned and I got the file containing my private key. But I don't know how can I use it in my POST request to be authenticated ?

POST Url: https://texttospeech.googleapis.com/v1beta1/text:synthesize and here is my POST body:

{ "audioConfig": { "audioEncoding": "LINEAR16", "pitch": "0.00", "speakingRate": "1.00" }, "input": { "text": "Hello World" }, "voice": { "languageCode": "en-US", "name": "en-US-Wavenet-E" } }


Solution

  • I found out that I need to create an API Key Credential from the following link: https://console.developers.google.com/apis/credentials?project=[your-project-name]

    and then append "?key=[API_KEY]" to my POST url and the authentication problem is fixed !