实时语音审核、第三方语音流及音频文件审核回调说明
网络协议
如果在请求参数中指定了回调地址参数 Callback,即一个 HTTP(S) 协议接口的 URL,则需要支持 POST 方法,传输数据编码采用 UTF-8。
URL Query 参数
名称 | 类型 | 是否必需 | 描述 |
Signature | string | 是 |
签名生成
Signature = Base64 ( HMAC-SHA1 ( strContent, SecretKey ))
strContent:签名原文串,为 POST+body 的整个 JSON 内容(长度以 Content-Length 为准)。
body:回调给业务的 JSON 内容,下方 回调示例 中的全部内容即为 body。
SecretKey:密钥,为应用的 SecretKey,可通过 控制台 > 应用详情 查看。
HMAC-SHA1:签名算法。
Base64:加密函数,进行 Base64 编码后,即可生成 Signature 签名。
将 Signature 加到 Url 的参数里,即可生成最终的回调请求。
回调示例
{"Code": 0,"DataId": "1400000000_test_data_id","ScanFinishTime": 1566720906,"HitFlag": true,"Live": false,"Msg": "","ScanPiece": [{"DumpUrl": "","HitFlag": true,"MainType": "abuse","RoomId": "123","OpenId": "1111","Info":"","Offset": 0,"Duration": 3400,"PieceStartTime":1574684231,"SubLabel": "PersonalAttack","ScanDetail": [{"EndTime": 1110,"KeyWord": "违规字","Label": "abuse","Rate": "90.00","StartTime": 1110}, {"EndTime": 1380,"KeyWord": "违规字","Label": "abuse","Rate": "90.00","StartTime": 930}, {"EndTime": 1560,"KeyWord": "违规字","Label": "abuse","Rate": "90.00","StartTime": 930}, {"EndTime": 2820,"KeyWord": "违规字","Label": "abuse","Rate": "90.00","StartTime": 2490}]}],"ScanStartTime": 1566720905,"Scenes": ["default"],"Status": "Success","TaskId": "6330xxxx-9xx7-11ed-98e3-52xxxxe4ac3b","Url": "https://xxx/xxx.m4a"}
语音消息审核回调说明
语音消息审核回调中,下载语音完成回调、转文本完成回调为客户端回调,在客户端接口中,除会返回原先的 code、filepath、fileid 外,还会增加 auditResult 的回调数据。审核结果回调为服务端回调。
客户端回调示例:
FileDownloadDelegateImpl filedAudioDownloadDelegate = new FileDownloadDelegateImpl(delegate (int code, string filepath, string fileid, string auditResult) {showLoadingView(false, "");if (code == 0){showWarningText("下载成功");InputField field = transform.Find("downloadFilePath").GetComponent<InputField>();field.text = filepath;InputField audioInput = transform.Find("auditResult").GetComponent<InputField>();audioInput.text = auditResult;}else{showWarningText("下载失败" + Convert.ToString(code));InputField field = transform.Find("downloadFilePath").GetComponent<InputField>();field.text = "";InputField audioInput = transform.Find("auditResult").GetComponent<InputField>();audioInput.text = auditResult;}});
语音消息审核回调参数:
名称 | 类型 | 描述 |
user_id | Number | 业务方玩家用户 ID。 |
player_uin | String | 业务方玩家用户 ID,字符串类型。 |
biz_id | Number | GME Sdkappid。 |
sign | String | 签名字符串。 |
audit_res | Number | 审核状态,对应如下: 1:审核完成。 2:审核中。 3:语言不支持。 4:没有勾选该语言选项。 |
DataId | String | 数据唯一标识。 |
HitFlag | Boolean | 是否违规。 true 违规。 false 不违规。 |
Label | String | 审核结果标签,对应如下: normal:正常文本。 politics: 政治。 porn:色情。 abuse:谩骂。 ad:广告。 illegal:违法。 terrorism:暴恐。 moan:呻吟/娇喘。 customized:自定义词库。 |
AsrText | String | 语音转文本结果。 |
Array of ScanDetail | 包含语音消息的审核结果和违规内容。 | |
RequestId | String | 唯一请求 ID,用于跟踪查询问题。 |
ScanDetail 字段说明:
名称 | 类型 | 描述 |
Label | String | 审核结果标签,对应如下: normal:正常文本。 politics: 政治。 porn:色情。 abuse:谩骂。 ad:广告。 illegal:违法。 terrorism:暴恐。 moan:呻吟/娇喘。 customized:自定义词库。 |
KeyWords | []String | 命中关键词 |
Rate | String | 置信度分数; 示例值:100 |
StartTime | Number | 违规事件结束时间,单位为秒(s); 示例值:15 |
EndTime | Number | 违规事件结束时间,单位为秒(s); 示例值:15 |
语音消息审核结果回调示例:
{"user_id": 9920413420219,"player_uin": "9920413420219","biz_id": 1400367018,"sign": "f7067c7020dc384879f273738f76319235d94aef60b7d83cec575a300e548199","audit_res": 1,"DataId": "A1A3E84F-4C9A-4A51-B7EC-10DFBC49959F","HitFlag": true,"Label": "porn","AsrText": "怎么,还想你的奶了?","ScanDetail": [{"Label": "porn","Rate": "72","StartTime": 0,"EndTime": 0}],"RequestId": "a61df1f6-e0e2-4a5b-805c-e277463d7bc3"}
语音消息审核回调验签说明:
审核回调结构体 sign 字段是待验签的字段。
步骤1:组成待签名的字符串
//待签名字符串body:"biz_id=" +biz_id + "&audit_res=" +audit_res+ "&DataId=" + DataId + "&Label=" + Label
步骤2:使用 sha256签名算法签名
func createSignature(signKey string, body string) string {mac := hmac.New(sha256.New, []byte(signKey))mac.Write([]byte(body))sha := hex.EncodeToString(mac.Sum(nil))return sha}