我想使用 Google Speech API 的异步转录服务。我已将我的音频文件上传到 Google 存储桶,并尝试将其与以下代码一起使用(我已从命令中删除了我的 key 和文件名,其他所有内容都已复制)。
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>
我收到 400 INVALID_ARGUMENT 错误,告诉我“请求包含无效参数”。我在 curl 请求中做错了什么?
最佳答案
显然问题出在我的 URI 中。谷歌有一种特殊的方式来引用谷歌存储桶中的项目,以“gs:”作为前缀。
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>
请注意,在切换到这种方法后,我遇到了一个无法克服的权限错误,但我认为这不再与我提出 curl 请求的方式有关。
关于json - Google 语音 API 的 INVALID_ARGUMENT 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44233974/