Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google speech api Invalid recognition

I am trying to follow the example on google speech api found here

https://cloud.google.com/speech/docs/getting-started

1) I created the follow json request file

{
    'config': {
          'encoding':'FLAC',
          'sampleRate': 16000,
          'languageCode': 'en-US'
    },
    'audio': {
         'uri':'gs://cloud-samples-tests/speech/brooklyn.flac'
    }
}

2) Authenticate to my service account

gcloud auth activate-service-account --key-file=service-account-key-file

3) Obtain my authorization token successfully

gcloud auth print-access-token
access_token

4) Then use the following curl command

curl -s -k -H "Content-Type: application/json" \
    -H "Authorization: Bearer access_token" \
    https://speech.googleapis.com/v1beta1/speech:syncrecognize \
    -d @sync-request.json

But I keep getting the following response

{
  "error": {
    "code": 400,
    "message": "Invalid recognition 'config': bad encoding..",
    "status": "INVALID_ARGUMENT"
  }
}

Do I need access permissions for the uri gs://cloud-samples-tests/speech/brooklyn.flac? Is that what the problem is?

Thanks in advance..

like image 899
msethi00 Avatar asked May 19 '26 14:05

msethi00


1 Answers

In my opinion, it is a file format issue.

You have to send WAV file instead of FLAC ...

[ FLAC and MP3 format are not supported <=> need a file conversion (representing cost) on the server side ]

Convert your audio file to WAV (using ffmpeg or avconv), then retry.

You may also take a look here (to see a working example)

like image 126
A STEFANI Avatar answered May 22 '26 08:05

A STEFANI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!