You*_*She 4 google-cloud-platform
我正在尝试使用Google Cloud Speech API将一个多小时的音频数据转换为文本,并且我正在使用API资源管理器,因为它很容易。
该请求看起来像这样。
POST https://speech.googleapis.com/v1/speech:longrunningrecognize?key={YOUR_API_KEY}
{
"audio": {
"uri": "gs://data/audio.flac"
},
"config": {
"encoding": "FLAC",
"languageCode": "en-US"
}
}
Run Code Online (Sandbox Code Playgroud)
响应如下所示。
200
Show headers
{
"name": "`numbers`"
}
Run Code Online (Sandbox Code Playgroud)
为什么只返回名称而不返回音频文本呢?
只是有同样的问题。
在https://cloud.google.com/speech/docs/async-recognize找到了答案
如果请求成功,服务器将返回200 OK HTTP状态代码和JSON格式的响应:
{
"name": "5543203840552489181"
}
Run Code Online (Sandbox Code Playgroud)
其中,name是为请求创建的长时间运行的操作的名称。等待大约30秒以完成处理。要检索操作结果,请发出GET请求:
GET https://speech.googleapis.com/v1/operations/YOUR_OPERATION_NAME?key=YOUR_API_KEY
Run Code Online (Sandbox Code Playgroud)
得到了我的结果:
curl -s -k -H "Content-Type: application/json" \
-H "Authorization: Bearer {access_token}" \
https://speech.googleapis.com/v1/operations/{name}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3215 次 |
| 最近记录: |