Google speech api isse

194 Views Asked by At

I am trying to use long transcribe using google API here is the code which I used

https://cloud.google.com/speech-to-text/docs/async-recognize?authuser=3

but it shows me an error. I don't know where I am doing something wrong. Please help me to solve this issue

Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "Specify FLAC encoding to match audio file.", "code": 3, "status": "INVALID_ARGUMENT", "details": [] }

1

There are 1 best solutions below

0
On

The error indicates that the audio file is a FLAC, but the configuration in the request has encoding other than FLAC.

It can be possible that the encoding field in your programming language is other than FLAC, or it wasn't even specified it. You can try the following example from Cloud Shell with your audio file to check if you have a successful response (don't forget to set up the GOOGLE_APPLICATION_CREDENTIALS variable):

curl -X POST      -H "Authorization: Bearer "$(gcloud auth application-default print-access-token)      -H "Content-Type: application/json; charset=utf-8"      --data "{
  'config': {
    'language_code': 'en-US',
    'encoding': 'FLAC'
  },
  'audio':{
    'uri':'gs://cloud-samples-tests/speech/brooklyn.flac'
  }
}" "https://speech.googleapis.com/v1/speech:longrunningrecognize"

If it works, you need to adjust your request in your programming language to include 'encoding':'FLAC'. If this doesn't solve the error, let us know the programming language you are using and the details of your request.