当我选择音频超过30秒或1分钟时,它的显示就会出现错误。
->同步输入时间过长。对于超过1分钟的音频,请使用带有“uri”参数的LongRunningRecognize。
-> https://speech.googleapis.com/v1p1beta1/speech:recognize?key="api key"
body -> {
"audio":{"content":" // base64 formated audio // "},
"config":{
"enableAutomaticPunctuation":true,
"encoding":"WEBM_OPUS",
"sampleRateHertz": 16000,
"languageCode":"en-US",
"model":"default"
}
}发布于 2022-05-02 00:33:37
对于超过1分钟的音频,您应该使用speech:longrunningrecognize端点。
使用key的端点是https://speech.googleapis.com/v1/speech:longrunningrecognize?key="api_key"
使用curl,我可以向这个端点发送请求:
curl -s -H "Content-Type: application/json" \
https://speech.googleapis.com/v1/speech:longrunningrecognize?key=AIzaSyD....\
-d "{
'config': {
'language_code': 'en-US'
},
'audio':{
'uri':'gs://cloud-samples-tests/speech/brooklyn.flac'
}
}"输出:
{
"name": "1521059426290567438"
}当请求发送到端点时,它将创建一个长时间运行的操作,并返回一个name。这将用于检查长时间运行操作的状态。可以通过向此端点https://speech.googleapis.com/v1/operations/<name>发送请求来检查状态。如果操作完成,它将返回响应中的记录。
检查状态:
curl -H "Content-Type: application/json; charset=utf-8" \
"https://speech.googleapis.com/v1/operations/1521059426290567438?key=AIzaSyD...."输出:

https://stackoverflow.com/questions/71857934
复制相似问题