状态回调
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"
}
转写服务失败回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "asr",
"status": "failed",
"appKey": "your_appkey",
"roomId": "111",
"code": 40001,
"errorMessage": "ASR Service Failed"
}
翻译回调
翻译服务回调除了包含通用字段外,还包含以下额外字段:
字段名称 | 类型 | 说明 |
---|---|---|
userId | String | 用户 ID,指明哪个用户的翻译服务 |
msLabel | String | 流标签,指明哪个流的翻译 |
srcLanguage | String | 翻译的原语言 |
targetLanguage | String | 翻译的目标语言 |
翻译服务开始回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "tr",
"status": "started",
"appKey": "your_appkey",
"roomId": "111",
"userId": "user123",
"msLabel": "user123_RongCloudRTC",
"srcLanguage": "zh",
"targetLanguage": "en",
"code": 10000,
"errorMessage": "Success"
}
翻译服务结束回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "tr",
"status": "stopped",
"appKey": "your_appkey",
"roomId": "111",
"userId": "user123",
"msLabel": "user123_RongCloudRTC",
"srcLanguage": "zh",
"targetLanguage": "en",
"code": 10000,
"errorMessage": "Success"
}
翻译服务异常回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "tr",
"status": "exception",
"appKey": "your_appkey",
"roomId": "111",
"userId": "user123",
"msLabel": "user123_RongCloudRTC",
"srcLanguage": "zh",
"targetLanguage": "en",
"code": 50001,
"errorMessage": "Translation Service Exception"
}
翻译服务失败回调
HTTP
POST /any-url-path HTTP/1.1
Host: your.app.server
Content-Type: application/json
{
"type": "tr",
"status": "failed",
"appKey": "your_appkey",
"roomId": "111",
"userId": "user123",
"msLabel": "user123_RongCloudRTC",
"srcLanguage": "zh",
"targetLanguage": "en",
"code": 40001,
"errorMessage": "Translation Service Failed"
}
响应回调请求
您的服务在收到 HTTP 回调之后, 需要返回 200 OK
表示接收成功。
回调状态码说明:
- 当语音识别或翻译服务出现故障时,会立即回调异常或失败状态。
- 建议在您收到异常或失败回调后检查服务的状态,并及时处理相关错误。
最后于 2025年1月27日 更新