Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error in Request for Google Cloud Speech API request

I'm getting this error when I make my request to the Google Cloud Speech API: "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT

My curl command looks like this: curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxx" \https://speech.googleapis.com/v1beta1/speech:syncrecognize -d @sync-request.json

and my config file like this:

      {
  'config': {
      'encoding':'FLAC',
      'sampleRate': 16000,
      'languageCode': 'de-DE'
  },
  'audio': {
      'uri':'https://storage.googleapis.com/project_name/xxxx_Ger16.flac'
  }
}

What is missing or invalid in the request? Thanks.

like image 907
topplethepat Avatar asked Apr 06 '17 16:04

topplethepat


People also ask

How do I see Google API errors?

Google APIs define a set of standard error payloads for error details, which you can find in google/rpc/error_details.

How does Google Cloud Speech API work?

A streaming Speech-to-Text API recognition call is designed for real-time capture and recognition of audio, within a bi-directional stream. Your application can send audio on the request stream, and receive interim and final recognition results on the response stream in real time.

Can Google Speech API be used offline?

Android does have offline speech recognition capabilities. You can activate this by going to Settings - Language and Input - Voice Input and touch the cog icon next to Enhanced Google Services.


1 Answers

The error message received suggests a property you've provided in your JSON request body is not valid. As you've confirmed in your comment, the audio.uri value for Cloud Storage resources should match the pattern gs://bucket_name/object_name.

The audio object in the request body of type RecognitionAudio. The documentation for this confirms your findings.

like image 168
Nicholas Avatar answered Sep 24 '22 03:09

Nicholas