Error messages

Learn how to resolve some errors raised by Cloud Speech-to-Text. This topic discusses errors whose resolutions require more steps than can be easily described in an error message.

"The Application Default Credentials are not available"

If you receive this message:

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.

Cloud Speech-to-Text uses Application Default Credentials for authentication.

You must have a service account for your project, download the key (JSON file) for your service account to your development environment, and then set the location of that JSON file to an environment variable named GOOGLE_APPLICATION_CREDENTIALS.

Furthermore, the GOOGLE_APPLICATION_CREDENTIALS environment variable must be available within the context that you call the Speech-to-Text API. For example, if you set the variable from within an terminal session but run your code in the debugger of your IDE, the execution context of your code might not have access to the variable. In that circumtance, your request to Cloud Speech-to-Text might fail for lack of proper authentication.

For more information on how to set the GOOGLE_APPLICATION_CREDENTIALS environment variable, see the Cloud Speech-to-Text quickstarts or the documentation on using the Application Default Credentials.

"File ... (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!"

If you receive this message:

ERROR: (gcloud.auth.application-default.print-access-token) File /path/to/key.json
(pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "status": "PERMISSION_DENIED"
  }
}

Verify that you have a valid service account key JSON file in the location stored in the GOOGLE_APPLICATION_CREDENTIALS environment variable and that the variable points to the correct place.

To diagnose this error, try opening the service account key file from the folder from which you're attempting to call the Speech-to-Text API.

cat $GOOGLE_APPLICATION_CREDENTIALS

"Must use single channel (mono) audio"

If you receive this message:

Must use single channel (mono) audio, but WAV header indicates 2
channels.

Your audio file contains more than one channel. To transcribe this audio file, you must declare that your audio has multiple channels.

"Must use 16 bit samples for LINEAR_PCM"

If you receive this message:

INVALID_ARGUMENT: Must use 16 bit samples for LINEAR_PCM, but the WAV
header indicates 8 bits per sample

You might need to change the encoding that you've specified in your RecognitionConfig. To read about supported encodings in Cloud Speech-to-Text, see the encodings guide.

"Sync input too long"

If you receive this message:

Sync input too long. For audio longer than 1 min use
LongRunningRecognize with a 'uri' parameter.

The synchronous recognize method for Cloud Speech-to-Text only supports transcribing audio data up to 1 minute in length. For longer audio data, use asynchronous recognize instead.

"Invalid recognition 'config': bad encoding"

If you receive this message:

Invalid recognition 'config': bad encoding.

Your audio data might not be encoded correctly or is encoded with a codec different than what you've declared in the RecognitionConfig. Check the audio input and make sure that you've set the encoding field correctly.

"Request payload size exceeds the limit"

If you receive this message:

Request payload size exceeds the limit.

Your audio data is too large in size. Review the quotas & limits for using Cloud Speech-to-Text.

"Quota exceeded"

If you receive this message:

RESOURCE_EXHAUSTED: Quota exceeded.

You have reached the limit of your per-minute or daily quota. Review the quotas & limits for using Cloud Speech-to-Text.

You can request an increase to your quotas from the Google Cloud Platform Console.

Hai trovato utile questa pagina? Facci sapere cosa ne pensi:

Invia feedback per...

Cloud Speech-to-Text Documentation
Hai bisogno di assistenza? Visita la nostra pagina di assistenza.