6

I am trying to use Google Cloud Speech recognition but I get this error

I/omputeEngineCredentials: Failed to detect whether we are running on Google Compute Engine. W/System.err: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

I set the environment variable from System Properties/Environment Variables/User variables and also I set the credentials manually using this guide.

I have searched every topic that is relevant to this, but I can't get it to work. What am I missing?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
stavros.3p
  • 2,244
  • 6
  • 20
  • 37
  • Can you paste the part of the code where you initialize the credentials? Can you also perform a `printenv` on your linux env (if your app run under linux)? – guillaume blaquiere Nov 23 '19 at 19:42
  • The error means exactly what it said. The answer is in the details, edit your question with more information: 1) Where is this code running (your desktop, Compute Engine, your phone, etc.) You added the tag "android" - why? 2) How are you running this code? Show the exact sequence/command line. 3) Show the code that is generating this error. 4) Don't say "I followed this guide". Show the exact steps you did follow in your question. You might have made a mistake. If necessary, redo everything so that you have a reproducible question. – John Hanley Nov 23 '19 at 22:02
  • have you made sure that the service account you are using had the appropriate roles/permissions..... https://cloud.google.com/iam/docs/overview – Paddy Popeye Nov 26 '19 at 11:18

2 Answers2

6

I faced this issue while connecting to Cloud Storage from local .Following are the steps I followed that worked for me:

  1. Install Cloud SDK. Reference link:Cloud SDK
  2. Follow all the steps to initialize the SDK.
  3. Now ,create application default credentials by using the following command in the root directory of your application gcloud auth application-default login, by which google-cloud will automatically detect your credentials.
snehab
  • 684
  • 5
  • 13
0

It is hard to say without access to logs and code, but probably you should start from debugging accesses to speech API from console directly. gcloud auth activate-service-account --key-file=[PATH] gcloud ml speech recognize 'gs://cloud-samples-tests/speech/brooklyn.flac' \ --language-code='en-US' https://cloud.google.com/blog/products/ai-machine-learning/ml-explorer-talking-and-listening-with-google-cloud-using-cloud-speech-and-text-to-speech

Possible reasons are: - API is disabled, - credential you use doesn't contains permissions for ML. - credential file path is wrong.

  • With the first gcloud command I got the result: Activated service account credentials for: [myapp.iam.gserviceaccount.com] . – stavros.3p Nov 23 '19 at 23:52
  • With the second command I get: ERROR: (gcloud.ml.speech.recognize) INVALID_ARGUMENT: Invalid recognition 'config': Bad language code. – stavros.3p Nov 23 '19 at 23:52
  • @student What is the language code you have used? (Ex: "en-US") – Yuvaraj S Mar 04 '20 at 13:47