状态回调
AI 智能流式语音识别和智能翻译在开始服务、服务结果、服务结束、服务异常的时候均提供 HTTP 状态回调,您可以获取服务状态信息和结果。如果您已开通「AI 智能流式语音识别」或「智能翻译」服务,并配置了公网可访问的回调 URL,融云会将服务的状态变化实时通知您在控制台配置的服务器地址。
请在控制台的 AI 智能流式语音识别页面,填写接收 HTTP 回调的 URL,配置后 15 分钟内生效。
回调方法
POST:<your-receiving-server-url>
数据格式:application/json
回调地址 <your-receiving-server-url>
是您在控制台为当前 App Key 和服务所配置的回调接收地址。请务必配置可正常访问的回调接收地址。如果您的网络有 IP 访问限制,请务必配置 IP 白名单,否则无法正常接收服务端回调。
为了验证数据有效性并确保调用者为融云 Server,每个请求前添加数据签名。回调签名规则详见服务端回调。
通用字段
下表描述了 AI 智能流式语音识别和智能翻译服务回调请求的通用字段:
字段名称 | 类型 | 说明 |
---|---|---|
type | String | 回调类型,asr 表示语音转写,tr 表示翻译 |
status | String | 回调事件类型,如下:started : 服务开始;stopped : 服务结束;exception : 任务异常;failed : 服务失败 |
appKey | String | 当前使用的 App Key。 |
roomId | String | 房间 ID 。 |
code | Number | 状态码,10000 为正常。 |
errorMessage | String | 错误信息,成功时为 "Success"。 |
语音转写回调
转写服务开始回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "asr",
"status": "started",
"appKey": "your_appkey",
"roomId": "111",
"code": 10000,
"errorMessage": "Success"
}
转写服务结束回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "asr",
"status": "stopped",
"appKey": "your_appkey",
"roomId": "111",
"code": 10000,
"errorMessage": "Success"
}
转写服务异常回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "asr",
"status": "exception",
"appKey": "your_appkey",
"roomId": "111",
"code": 50001,
"errorMessage": "ASR Service Exception"
}