音频文件转写-查询结果
更新时间:2025-04-17
配合音频文件转写接口使用,用于在生成转写任务后查询转写结果。
POST
https://aip.baidubce.com/rpc/2.0/aasr/v1/query
将生成转写任务时返回的task_id传入,获取对应任务的处理状态。
权限说明
调用本能力需要使用API Key进行鉴权认证。获取及使用API Key的流程请参考:APIKey鉴权说明文档
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
task_ids
array
任务id。单次查询任务数不超过200个
可选
显示子属性
隐藏子属性
items
string
具体每个任务的id
请求结构
POST https://aip.baidubce.com/rpc/2.0/aasr/v1/query
Authorization: API Key String
Content-Type: application/json
{
"task_ids": ["234acb234acb234acb234acb", "234acb234acb234acb234acd", "234acb234acb234acb234acbe"]
}
示例代码
请求示例
curl --location --request POST 'https://aip.baidubce.com/rpc/2.0/aasr/v1/query' \
--header 'Authorization: Bearer bce-v3/ALTAK-*********/614fb**********' \
--header 'Content-Type: application/json' \
--data-raw '{
"task_ids": ["67d3d62f9039849d01b6ed03"] ##调用转写请求接口时返回的任务id
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
log_id
string
用于问题排查,一般可忽略
可选
tasks_info
object {3}
任务的结果
可选
显示子属性
隐藏子属性
task_id
string
任务id
可选
task_status
string
任务状态
可选
task_result
object {4}
转写结果的json格式
可选
显示子属性
隐藏子属性
corpus_no
string
日志,反馈问题时使用
可选
result
string
转写结果
可选
audio_duration
string
音频时长(毫秒)
可选
detailed_result
object {5}
分段转写详细结果
可选
显示子属性
隐藏子属性
res
string
分段转写文本
可选
begin_time
string
分段开始时间
可选
end_time
string
分段结束时间
可选
sn
string
分段日志,反馈问题时使用
可选
corpus_no
string
分段日志,反馈问题时使用
可选
响应示例
{
"log_id": 12345678,
"tasks_info": [
{ # 转写中
"task_status": "Running"
"task_id": "234acb234acb234acb234acb",
},
{ # 转写失败
"task_status": "Failure"
"task_id": "234acb234acb234acb234acd",
"task_result": {
"err_no": 3301
"err_msg": "speech quality error",
"sn": "xxx"
}
},
{ # 转写成功
"task_status": "Success",
"task_result": {
"result": [
"观众朋友大家好,欢迎收看本期视频哦。毕竟..."
],
"audio_duration": 6800,
"detailed_result": [
{
"res": [
"观众朋友大家好,欢迎收看本期视频哦。"
],
"end_time": 6700,
"begin_time": 4240,
"words_info": [],
"sn": "257826606251573543780",
"corpus_no": "6758319075297447880"
}
...
],
"corpus_no": "6758319075297447880"
},
"task_id": "234acb234acb234acb234ace"
}
]
}
音频转写结果错误码
err_no | err_msg | 描述 |
---|---|---|
3301 | speech quality error. | 音频文件格式不对 |
4001 | open speech file failed | 打开音频文件失败 |
4002 | speech length too short | 音频文件长度太短 |
4003 | internal error | 内部错误 |
4008 | invalid input | 无效语音 |
4009 | speech length too short | 音频文件长度太短 |
4010 | invalid input | 无效语音 |
4016 | not support speech format | 音频格式错误,不是pcm或者wav |
4017 | not support rate | 采样率错误,非16000或8000 |
4018 | read speech file failed | 读音频文件失败 |
4041 | invalid input | 无效语音 |
100000 | asr task internal error | 任务内部错误 |
100001 | asr task running timeout | 任务运行超时 |
100101 | illegal speech url format | url格式非法 |
100102 | request timeout to speech url | http请求超时 |
100103 | request error to speech url | http请求错误,检查音频url链接,如没有问题请反馈工单排查 |
100104 | invalid response from speech url | 返回无效数据,http status 非200,回包body为空等 |
100105 | invalid speech size | 回包大小超限,音频最大100MB |
100201 | not support speech format | 不支持音频格式 |
100202 | speech transcoding failed | 文件转码失败 |
100203 | not support pid | 不支持的pid |
100204 | not support rate | 不支持的rate |
100205 | audio file is faulty | 无法解析格式的音频 |
100206 | Not support vad | VAD大小超限不支持 |
100207 | Not support channel | 通道数超限不支持 |
100010 | asr task internal error | 内部错误 |
100020 | Authentication and Rate Limit Failed | 鉴权或流控失败 |
100022 | An http exception occurred during Authentication and Rate Limitation | 鉴权或流控过程中HTTP出错 |
200100 | Invalid parameter | 参数错误 |
200108 | Invalid user id | 用户id参数错误 |
200115 | Invalid AppID or no permission | AppID参数错误 |