changemyminds / Google-Cloud-TTS-Android

Google Cloud Platform Text To Speech library use API_KEY on Android Library.
52 stars 23 forks source link

403 error load voice list #1

Open samy-baili opened 6 years ago

samy-baili commented 6 years ago

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

changemyminds commented 6 years ago

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.

KGoch commented 5 years ago

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?

changemyminds commented 5 years ago

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

rahulfromearth commented 4 years ago

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

aseelalawy commented 3 years ago

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...

changemyminds commented 3 years ago

@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
}
dre-dev commented 3 years ago

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