Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INVALID_ARGUMENT error by Google speech API

I want to use Google Speech API's asynchronous transcription service. I've uploaded my audio file on Google buckets and I'm trying to use it with the following code (I've removed my key and my filename from the command, everything else is copied).

curl -H "Content-Type: application/json" 
    --data '{"audio":{"uri":"https://storage.cloud.google.com/<mybucketname>/<filename>"},
    "config":{"encoding":"FLAC","sample_rate_hertz":"16000","language_code":"en_US"}}' 
    https://speech.googleapis.com/v1/speech:longrunningrecognize?key=<mykey>

I get a 400 INVALID_ARGUMENT error telling me "Request contains an invalid argument". What am I doing wrong in my curl request?

like image 414
Roozbehan Avatar asked Nov 08 '22 21:11

Roozbehan


1 Answers

Apparently the problem was in my URI. Google has a special way for referencing items in Google buckets, with "gs:" as the prefix.

curl -H "Content-Type: application/json" 
    --data '{"audio":{"uri":"gs://<mybucketname>/<filename>"},
    "config":{"encoding":"FLAC","sample_rate_hertz":"16000","language_code":"en_US"}}' 
    https://speech.googleapis.com/v1/speech:longrunningrecognize?key=<mykey>

Note that I got a permission error that I could not overcome after I switched to this approach, but I don't think this is related to the way I'm making my curl request anymore.

like image 59
Roozbehan Avatar answered Nov 15 '22 06:11

Roozbehan