Google-Cloud-TTS-Android icon indicating copy to clipboard operation
Google-Cloud-TTS-Android copied to clipboard

403 error load voice list

Open samy-baili opened this issue 6 years ago • 7 comments

I got a 403 error, even when I am replacing the api_key

samy-baili avatar Oct 01 '18 13:10 samy-baili

Your api_key application limit may be wrong. You need to choose Application restrictions [None]. Because Application restrictions [Android apps] google don't support gcp text to speech for android.

If you don't know how to change. The following are the steps.

go to here and select credentials. Select your api_key and edit. Find Application restrictions and select None and test it.

image

If you have some problem please let me know. Thank you.

changemyminds avatar Oct 01 '18 15:10 changemyminds

Hi, Thank you for this nice project ;). Same error here whereas I have created a new API key with app restriction set to None. However, the API key is configured into a project with different package than yours. Is that a problem?

KGoch avatar Oct 25 '18 09:10 KGoch

No. Do you have the error code ? Just like 401 or 403 etc...

changemyminds avatar Nov 13 '18 00:11 changemyminds

To remove the error, you'll have to enable the Cloud TTS API in your GCP console. You can enable it here.

rahulfromearth avatar Dec 01 '19 00:12 rahulfromearth

E/MainActivityPresenter: Loading Voice List Error, error code : 403 l have enable the Cloud TTS API in your GCP console and I have created a new API key with app restriction set to None. and still the same problem 403...

aseelalawy avatar Dec 08 '20 19:12 aseelalawy

@aseelalawy Did you enable the Google cloud TTS api in your in your GCP console ?

Use the curl command and replace the below text YOUR_API_KEY to your google api key.

curl -H "X-Goog-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data "{
    'input':{
      'text':'Hello I am david, Nice to meet you'
    },
    'voice':{
      'languageCode':'en-gb',
      'name':'en-GB-Standard-A',
      'ssmlGender':'FEMALE'
    },
    'audioConfig':{
      'audioEncoding':'MP3'
    }
  }" "https://texttospeech.googleapis.com/v1/text:synthesize"

If you don't enable the google cloud text to speech you will get the error message.

{
  "error": {
    "code": 403,
    "message": "Cloud Text-to-Speech API has not been used in project project-id before or it is disabled. Ena
ble it by visiting https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=project-id then retry. 
If you enabled this API recently, wait a few minutes for the action to propagate to oursystems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/texttospeech.googleapis.com/overview?project=
project-id"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "texttospeech.googleapis.com",
          "consumer": "projects/project-id"
        }
      }
    ]
  }
}

Otherwise, you will get the correct message.

{
  "audioContent": "//NExAASqroAABhGudE...." // some base64 string
}

changemyminds avatar Dec 21 '20 07:12 changemyminds

The same thing happened when I run this code in terminal for AutoML. curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" https://automl.googleapis.com/v1beta1/projects/121865889356/locations/us-central1/models/IOD5152058600083947520:predict -d @request.json

dre-dev avatar Jan 18 '21 06:01 dre-dev