Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Text-to-Speech API - permission error

I am attempting to set up Google Cloud Text-to-Speech API following these instructions - https://cloud.google.com/text-to-speech/docs/quickstart I have successfully followed steps 1-6 for setting up Google SDK and authenticating with service account credentials. However, when I attempt to run the sample HTTP request for synthesising speech I receive the following error:

Cloud Text-to-Speech API has not been used in project usable-auth-library before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=usable-auth-library then retry.

When following the link in the error message it leads to the following page:

The API "texttospeech.googleapis.com" doesn't exist or you don't have permission to access it.

I am grateful for help.

like image 366
MKB Avatar asked Apr 12 '18 15:04

MKB


People also ask

Is Google Text-to-Speech API free?

Text-to-Speech is priced based on the number of characters sent to the service to be synthesized into audio each month. You must enable billing to use Text-to-Speech, and will be automatically charged if your usage exceeds the number of free characters allowed per month.

What is Google Text-to-Speech API?

Google Cloud Text-to-Speech API (Beta) allows developers to include natural-sounding, synthetic human speech as playable audio in their applications.


2 Answers

I easier to integrate in most plarforms using the API key instead of the service account key that Google recomends on their docs.

These are all the steps you need to get to the the API key

  1. Create a project (or use an existing one) in the Cloud Console.
  2. Make sure that billing is enabled for your project.
  3. Enable the Text-to-Speech API.
  4. Create an API key.

You'll probably only need the last step (if you followed all the steps correctly like you said).

And then you can use the curl command like so

Curl -H "X-Goog-Api-Key: PUT_YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data "{
    'input':{
      'text':'Android is a mobile operating system developed by Google,
         based on the Linux kernel and designed primarily for
         touchscreen mobile devices such as smartphones and tablets.'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-text.txt
like image 117
Alejandro Cotilla Avatar answered Oct 23 '22 12:10

Alejandro Cotilla


In case this helps anyone, I ran into this error after adding the API through the Google console to an existing Google Service Account with JWT credentials.

I followed the link to the Quickstart Protocol and was able to get it working On the page below, I clicked on Enable the API.

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

Text-to-Speech Quickstart

On the next page, I clicked the Create a project drop down and selected an existing project. There was no need to get new credentials.

enter image description here

I'm using Go and was then able to run my code using golang.org/x/oauth2/google.

like image 1
Grokify Avatar answered Oct 23 '22 14:10

Grokify