语音文件异步接口

  • 国内: http://api.speech.tuputech.com/v3/recognition/speech/recording/async/<secretId>

secretId 需替换为您的 secretId,请联系我们为您开通 secretId。

http 请求方法:POST

http Content-type: application/json

并发限制:测试期允许最多同时处理 3 个文件,正式使用请与我们沟通协商

请求示例:

{
  "recording": {
    "url": "http://www.tupu.com/test.mp3",
    "callbackUrl": "http://your_cb.com",
    "roomId": "your_room_id",
    "userId": "your_user_id",
    "forumId": "your_forum_id",
    "customInfo": {
      "hello": true,
      "other": "your other message"
    }
  },
  "timestamp": 1541499770,
  "nonce": 0.8469537531104208,
  "signature": "your_signature"
}

请求参数说明

参数名 类型 是否必填 说明
recording Object 是 录音文件信息,详见下面说明
timestamp Number 是 当前的服务器的 Unix 时间戳
nonce Number 是 随机数
signature String 是 我们采用的数字证书签名算法是:"RSA-SHA256",签名输出类型是:"base64",具体步骤如下:
1、所有参与签名的参数为:secretId,timestamp,nonce,用英文半角逗号“,”相连,得到sign_string;
2、利用您的私钥,使用算法"RSA-SHA256"签名,输出为 "base64" 格式,得到参数signature的值。
点击管理公钥证书查看如何生成私钥,及如何上传您的公钥用于数字签名的认证;
tasks Array 否 指定运行的任务 ID 列表

文件限制

大小限制:100M 以内;
允许识别的格式:amr, mp3, wmv, wav, flv;

recording 参数说明:

参数名 类型 是否必填 说明
url String 是 音频文件地址;大小限制:100M 以内;允许识别的格式:amr, mp3, wmv, wav, flv, m4a
callbackUrl String 否 检测结果的回调地址(支持http, https)。失败重试 2 次,需自行保证回调地址正常
callbackRule String 否 不传值表示出现违规才回调;all 表示回调全部结果
roomId String 否 房间 ID
language String 否 需要识别的语言代码。需要进行多语种语音转译审核或者多语种转译时必传。多语种语音转译类产品需联系图普进行配置使用。对应语言代码详见:语音转译审核(多语种)
userId String 否 用户 ID
forumId String 否 板块 ID ,数据 ID
customInfo Object 否 自定义信息,用于给请求附加额外信息(比如:关联的信息)。

curl 请求示例

不指定任务

curl -X POST --header 'Content-Type: application/json' \
-d '{
    "recording": {
        "url": "rtmp://pili-Room-4daedc9c7a5db36c325f6609000c0201",
        "callbackUrl": "http://www.tupu.com/callback",
        "callbackRule": "all",
        "roomId": "111111",
        "userId": "23231",
        "forumId": "321313",
        "customInfo": {
          "hello": true,
          "other": "your other message"
        }
    },
    "timestamp": 1541499770,
    "nonce": 0.8469537531104208,
    "signature": "CsIMcHuWqn/QFEnHWcFEhrB7ydcg5xTKawpRpNqA9Nw2WlCVIDR5jDcyUF85"
}' \
'http://api.speech.tuputech.com/v3/recognition/speech/recording/async/your_secretId'

指定任务

curl -X POST --header 'Content-Type: application/json' \
-d '{
    "recording": {
        "url": "rtmp://pili-Room-4daedc9c7a5db36c325f6609000c0201",
        "callbackUrl": "http://www.tupu.com/callback",
        "callbackRule": "all",
        "roomId": "111111",
        "userId": "23231",
        "forumId": "321313",
        "customInfo": {
          "hello": true,
          "other": "your other message"
        }
    },
    "timestamp": 1541499770,
    "nonce": 0.8469537531104208,
    "signature": "CsIMcHuWqn/QFEnHWcFEhrB7ydcg5xTKawpRpNqA9Nw2WlCVIDR5jDcyUF85",
    "tasks": [ "5caee6b2a76925c55a09a6d2", "5c8213b9bc807806aab0a574" ]
}' \
'http://api.speech.tuputech.com/v3/recognition/speech/recording/async/your_secretId'

返回参数说明

注意:同步请求及异步回调结果都是此结构,不同的是 json 里的信息

请求的同步响应

json 字段数据示例:

{
  "result": {
    "requestId": "tupu_request_id",
    "url": "http://www.tupu.com/test.mp3",
    "callbackUrl": "http://your_cb.com",
    "callbackRule": "all",
    "roomId": "your_room_id",
    "userId": "your_user_id",
    "forumId": "your_forum_id",
    "customInfo": {
      "hello": true,
      "other": "your other message"
    }
  },
  "code": 0,
  "message": "success",
  "nonce": "0.01627771095362096",
  "timestamp": 1552391372490
}

结果的数据结构

参数名 类型 是否必有 说明
result Array 是 详见以下 result 数据结构

result 数据结构

参数名 类型 是否必有 说明
requestId String 是 客户提交的音频的唯一请求 id,后续可以通过该 id 查到音频的相关信息
url String 是 音频文件地址
callbackUrl String 否 检测结果的回调地址
roomId String 否 房间 ID
userId String 否 用户 ID
forumId String 否 板块 ID ,数据 ID
customInfo Object 否 自定义信息,用于给请求附加额外信息(比如:关联的信息)。

回调结果

回调请求

http 请求地址:request callbackUrl 参数值里的地址

http 请求方法:POST

http Content-type: application/json

发送端判断回调是否成功

http 状态为 200 则表示回调成功,所以客户端成功收到回调后,需尽快响应并携带 200 状态码,防止回调重复发送

回调结果 json 里的公共结构

结果的数据结构

参数名 类型 是否必有 说明
requestId String 是 客户提交的音频的唯一请求 id
speechInfo Object 是 语音文件信息
roomId String 否 房间 ID
userId String 否 用户 ID
forumId String 否 板块 ID ,数据 ID
customInfo Object 否 自定义信息,用于给请求附加额外信息(比如:关联的信息)。
任务 id Object 是 审核任务的 id,结构详见以下描述
speechInfo
参数名 类型 是否必有 说明
duration Number 是 语音文件时长,单位:秒

results matching ""

    No results matching ""