音频特征检测接口
更新时间:
参数规范
请求URL: https://asr.ilivedata.com/api/v1/characteristic/detect
HTTP请求Header:
Header
值
描述
Content-Type
application/json;charset=UTF-8
请求体类型
Accept
application/json;charset=UTF-8
接受的返回类型
X-AppId
项目或应用的唯一标识符
X-TimeStamp
请求的UTC时间戳。需要把时间戳按W3C标准格式化,例如: 2010-01-31T23:59:59Z. (http://www.w3.org/TR/xmlschema-2/#dateTime)。
Authorization
签名值
请求方法:POST
请求体:
参数
类型
必需
描述
url
String
必需
音频url
gender
Boolean
可选
性别检测开关
userId
String
可选
用户ID
请求体示例
{
"url": "https://example.com/test.mp3",
"gender": true,
"userId": "12345678"
}
请求签名:
当用户请求 API时,可以使用appId和secretKey对请求做签名,当API收到带签名信息的请求之后,将使用相同的算法验证签名,如果发现签名不一致,API将会返回401给用户。
如果API验证签名一致,且appId对应的用户有权限操作请求的资源,则请求成功,否则API返回401。
通过 HTTP 请求 Header 发送签名
方法: 在请求中加入名为 Authorization 的 Header,值为签名值。如下:
Authorization: Njl86M/jY6zZaZoGhZdGO+GI/8+yGFECusGH1yQHUFE=
签名计算方法
1.构造规范化的请求字符串(Canonicalized Query String)
将请求体JSON字符串以UTF-8字符编码做sha256编码后转换为16进制字符串(注意不是Base64)
CanonicalizedQueryString = hex(sha256(jsonBody))
2.构造被签名字符串 StringToSign ("\n” 代表ASCII里的换行符)
StringToSign = HTTPMethod + "\n" +
HostHeaderInLowercase + "\n" +
HTTPRequestURI + "\n" +
CanonicalizedQueryString <从上一步得到> + "\n" +
"X-AppId:" + SAME_APPID_IN_HEADER + "\n" +
"X-TimeStamp:" + SAME_TIMESTAMP_IN_HEADER
HTTPRequestURI是请求URI的绝对路径,不包含请求串。如果HTTPRequestURI为空,也要保留一个正斜杠 ( / )
使用 HMAC-SHA256 协议创建基于哈希的消息身份验证代码 (HMAC),然后计算签名。
3.StringToSign作为签名字符串,secretKey作为秘钥,SHA256作为哈希算法
有关 HMAC 的更多信息,请参阅 https://tools.ietf.org/html/rfc2104。
4.将上一步的结果转换为BASE64串
5.将BASE64串放入HTTP请求Header的Authorization
签名示例
下面是appId & secretKey & audio的示例
appId=1000
secrectKey=d9e23d93053f49ade2f8fce185acedd4
audio_base64="IyFBTVItV0IKJFACQCLrVZflEqx2xCbkB6pst/TYz3z1zlzeTPXgvU5/1vL8JXZG7HAk8BjHC86gmnGNH8QWhxO5mEyWGtFkq9CouG9SOClwaOr9Kt0RNSmbeCTHbGX+taLPQd+7HdvywAGxCDPMFlPqnFHjydnHiiXHyU1VTsE/nKrYJOJK2LIhWO6gG64xtXJCruyM6SEWkOoNxv5FxHJl1F7mtQgFoSgrOqgkjRrt+LCU5rF/9UcBdY34U1kQYcIeO841udarlTvFettHhcsLDDOXUCTAGtvFChDs4ZluWLdmgXd6CSAEj+pjiphbznAHt/RMLf3yVmwn7wWgJOGaz7MGtt6EO7PY3vSHNrfR3SRjqZxWv1MtVwbGA1qoy/2EKHqJTJAk6Frfe0CWnjV4jHnHdqcYkyN/aqKXmQXZ65fpIMiq80/IeivSMJ9pQCTSWsTkDvmbI8sgHB+LFYBrV/qs9VOAqXkR6AqWVJizD6bkB6YpftSoJMgaoe3Nu/uVGado1moT4SCfIYGXfnlJ+PwyUixHjSvvx5xrqXzhjGAk4hjkuElyrLGt1yaSPlZu7OFRXGoL1s9ZKM881CLE6bSmPqbKdtHNsCTyGtZNTRyX16Gq2BX3gdldMRUnL9j0A1pIywdDpqIt2nPBkopalimwJMhY21G7IvjyPG2/XxQAs6zl1FTrK1gdu+Qk2tX59rIjIdb+OkigThgkwBjPBk0222EZhzbd+oHZzk4ZpH5akgCx95KcX7oek+ibSlBieDt1QCThObPv4BDJ4Z3vx5vOizPy247aMT3DrU0Pr8ucv3OJkjPUOWz2yzoYJMB8dlsXJojlm2pmGUUNwgvqTIaT+Usoeoy504PFJhMpkOV4BpImUyAkwDzXTwYx/cI5qUrOFsjs7M5JbB4X5xN8S7POvgT4Vh98PMHmHutxUCTAHSHqhTqycBhiSlCeBK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lGXacF/8FLrNCzdpT5a46AxBpmd0Kv+TlrtdZGf2XrVAkwHjW1R8u82GaT+7aNMILakfO7pFYRP3mfDi8z5adRos7S2Yq3eqIYCTBHc1gGYiaJV39YgfBFuk8eWY0JYrZuSd7cMSNrYTMcDvArF6c0qU4JOOUMGROqL7g2jDkAIbhXE9MX3tQBaLfy2Bep0j6c6PSmxX1ApQ+NMAkwEmYs7UAcnUf78lOMztwHjhmjkHxmV2gcpWg3hzgtbW7gVN/fEEG+CTwBPCuBCj74D3WSIMaqu7unq0OquBJjCpU4olkDAYYoBwJvFpASOTo"
下面是示例请求体
{"url":"https://example.com/test.mp3","gender":true, "userId":"12345678"}
生成CanonicalizedQueryString
b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
生成StringToSign
POST
asr.ilivedata.com
/api/v1/characteristic/detect
b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
X-AppId:1000
X-TimeStamp:2020-07-31T07:59:03Z
HMAC计算得到的签名
H0ZXsKUaiRotpxSiXW6+RgKRwnxHXy3qwlVzavs9iHo=
HTTP响应
Content-Type: application/json;charset=UTF-8
结果为JSON格式,请参考以下示例。
HTTP响应返回JSON字段说明:
字段名
类型
描述
errorCode
number
0表示成功
errorMessage
String
错误消息
taskId
String
任务Id
result
DetectResult
检测结果
DetectResult
字段名
类型
描述
gender
GenderResult
性别检测结果详情
GenderResult
字段名
类型
描述
type
String
结果值: female(女)、male(男)、unknown(无人声)
score
Float
检测结果置信度,值范围 0—1
响应示例
{
"errorCode": 0,
"errorMessage": "OK",
"taskId": "f7919cf1a5fc4f32a5d3fe576655416a",
"result": {
"gender": {
"type": "female",
"score": 1.0
}
}
}
错误码:
Http状态码
错误码
错误消息
200
0
此字段省略
405
1004
Method Not Allowed
411
1007
Not Content Length
400
1002
API Not Found
400
1003
Bad Request
400
2000
Missing Parameter
400
2001
Invalid Parameter
400
2002
Invalid Request
400
2102
Input Too Long
400
2103
Detection Failed
400
2109
Speech Recognition Failed
400
2110
File is invalid
400
2111
Failed to download file
400
2112
TaskId is invalid
401
1102
Unauthorized Client
401
1106
Missing Access Token
401
1107
Invalid Token
401
1108
Expired Token
401
1110
Invalid Client
参数规范
请求URL: https://asr.ilivedata.com/api/v1/characteristic/detect
HTTP请求Header:
Header | 值 | 描述 |
---|---|---|
Content-Type | application/json;charset=UTF-8 | 请求体类型 |
Accept | application/json;charset=UTF-8 | 接受的返回类型 |
X-AppId | 项目或应用的唯一标识符 | |
X-TimeStamp | 请求的UTC时间戳。需要把时间戳按W3C标准格式化,例如: 2010-01-31T23:59:59Z. (http://www.w3.org/TR/xmlschema-2/#dateTime)。 | |
Authorization | 签名值 |
请求方法:POST
请求体:
参数 | 类型 | 必需 | 描述 |
---|---|---|---|
url | String | 必需 | 音频url |
gender | Boolean | 可选 | 性别检测开关 |
userId | String | 可选 | 用户ID |
请求体示例
{
"url": "https://example.com/test.mp3",
"gender": true,
"userId": "12345678"
}
请求签名:
当用户请求 API时,可以使用appId和secretKey对请求做签名,当API收到带签名信息的请求之后,将使用相同的算法验证签名,如果发现签名不一致,API将会返回401给用户。
如果API验证签名一致,且appId对应的用户有权限操作请求的资源,则请求成功,否则API返回401。
通过 HTTP 请求 Header 发送签名
方法: 在请求中加入名为 Authorization 的 Header,值为签名值。如下:
Authorization: Njl86M/jY6zZaZoGhZdGO+GI/8+yGFECusGH1yQHUFE=
签名计算方法
1.构造规范化的请求字符串(Canonicalized Query String)
将请求体JSON字符串以UTF-8字符编码做sha256编码后转换为16进制字符串(注意不是Base64)
CanonicalizedQueryString = hex(sha256(jsonBody))
2.构造被签名字符串 StringToSign ("\n” 代表ASCII里的换行符)
StringToSign = HTTPMethod + "\n" +
HostHeaderInLowercase + "\n" +
HTTPRequestURI + "\n" +
CanonicalizedQueryString <从上一步得到> + "\n" +
"X-AppId:" + SAME_APPID_IN_HEADER + "\n" +
"X-TimeStamp:" + SAME_TIMESTAMP_IN_HEADER
HTTPRequestURI是请求URI的绝对路径,不包含请求串。如果HTTPRequestURI为空,也要保留一个正斜杠 ( / ) 使用 HMAC-SHA256 协议创建基于哈希的消息身份验证代码 (HMAC),然后计算签名。
3.StringToSign作为签名字符串,secretKey作为秘钥,SHA256作为哈希算法
有关 HMAC 的更多信息,请参阅 https://tools.ietf.org/html/rfc2104。
4.将上一步的结果转换为BASE64串
5.将BASE64串放入HTTP请求Header的Authorization
签名示例
下面是appId & secretKey & audio的示例
appId=1000
secrectKey=d9e23d93053f49ade2f8fce185acedd4
audio_base64="IyFBTVItV0IKJFACQCLrVZflEqx2xCbkB6pst/TYz3z1zlzeTPXgvU5/1vL8JXZG7HAk8BjHC86gmnGNH8QWhxO5mEyWGtFkq9CouG9SOClwaOr9Kt0RNSmbeCTHbGX+taLPQd+7HdvywAGxCDPMFlPqnFHjydnHiiXHyU1VTsE/nKrYJOJK2LIhWO6gG64xtXJCruyM6SEWkOoNxv5FxHJl1F7mtQgFoSgrOqgkjRrt+LCU5rF/9UcBdY34U1kQYcIeO841udarlTvFettHhcsLDDOXUCTAGtvFChDs4ZluWLdmgXd6CSAEj+pjiphbznAHt/RMLf3yVmwn7wWgJOGaz7MGtt6EO7PY3vSHNrfR3SRjqZxWv1MtVwbGA1qoy/2EKHqJTJAk6Frfe0CWnjV4jHnHdqcYkyN/aqKXmQXZ65fpIMiq80/IeivSMJ9pQCTSWsTkDvmbI8sgHB+LFYBrV/qs9VOAqXkR6AqWVJizD6bkB6YpftSoJMgaoe3Nu/uVGado1moT4SCfIYGXfnlJ+PwyUixHjSvvx5xrqXzhjGAk4hjkuElyrLGt1yaSPlZu7OFRXGoL1s9ZKM881CLE6bSmPqbKdtHNsCTyGtZNTRyX16Gq2BX3gdldMRUnL9j0A1pIywdDpqIt2nPBkopalimwJMhY21G7IvjyPG2/XxQAs6zl1FTrK1gdu+Qk2tX59rIjIdb+OkigThgkwBjPBk0222EZhzbd+oHZzk4ZpH5akgCx95KcX7oek+ibSlBieDt1QCThObPv4BDJ4Z3vx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GkgkzHyhI3QJER9Iv4oXcbSa1HMZLd/nFknbJO4msJ9ZvaXgkwDoT7mAmSFM7LURoMWZQri+3DVmvrfvAO4LTuB/tNL4msGfncPVh6CTADjKtDbLHMT9U788m5u2rYTB834Ii6PcNHSMFtnOZy5hq0PUiFuvwJMAd4n4vdjNlGXacF/8FLrNCzdpT5a46AxBpmd0Kv+TlrtdZGf2XrVAkwHjW1R8u82GaT+7aNMILakfO7pFYRP3mfDi8z5adRos7S2Yq3eqIYCTBHc1gGYiaJV39YgfBFuk8eWY0JYrZuSd7cMSNrYTMcDvArF6c0qU4JOOUMGROqL7g2jDkAIbhXE9MX3tQBaLfy2Bep0j6c6PSmxX1ApQ+NMAkwEmYs7UAcnUf78lOMztwHjhmjkHxmV2gcpWg3hzgtbW7gVN/fEEG+CTwBPCuBCj74D3WSIMaqu7unq0OquBJjCpU4olkDAYYoBwJvFpASOTo"
下面是示例请求体
{"url":"https://example.com/test.mp3","gender":true, "userId":"12345678"}
生成CanonicalizedQueryString
b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
生成StringToSign
POST
asr.ilivedata.com
/api/v1/characteristic/detect
b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
X-AppId:1000
X-TimeStamp:2020-07-31T07:59:03Z
HMAC计算得到的签名
H0ZXsKUaiRotpxSiXW6+RgKRwnxHXy3qwlVzavs9iHo=
HTTP响应
Content-Type: application/json;charset=UTF-8 结果为JSON格式,请参考以下示例。
HTTP响应返回JSON字段说明:
字段名 | 类型 | 描述 |
---|---|---|
errorCode | number | 0表示成功 |
errorMessage | String | 错误消息 |
taskId | String | 任务Id |
result | DetectResult | 检测结果 |
DetectResult
字段名 | 类型 | 描述 |
---|---|---|
gender | GenderResult | 性别检测结果详情 |
GenderResult
字段名 | 类型 | 描述 |
---|---|---|
type | String | 结果值: female(女)、male(男)、unknown(无人声) |
score | Float | 检测结果置信度,值范围 0—1 |
响应示例
{
"errorCode": 0,
"errorMessage": "OK",
"taskId": "f7919cf1a5fc4f32a5d3fe576655416a",
"result": {
"gender": {
"type": "female",
"score": 1.0
}
}
}
错误码:
Http状态码 | 错误码 | 错误消息 |
---|---|---|
200 | 0 | 此字段省略 |
405 | 1004 | Method Not Allowed |
411 | 1007 | Not Content Length |
400 | 1002 | API Not Found |
400 | 1003 | Bad Request |
400 | 2000 | Missing Parameter |
400 | 2001 | Invalid Parameter |
400 | 2002 | Invalid Request |
400 | 2102 | Input Too Long |
400 | 2103 | Detection Failed |
400 | 2109 | Speech Recognition Failed |
400 | 2110 | File is invalid |
400 | 2111 | Failed to download file |
400 | 2112 | TaskId is invalid |
401 | 1102 | Unauthorized Client |
401 | 1106 | Missing Access Token |
401 | 1107 | Invalid Token |
401 | 1108 | Expired Token |
401 | 1110 | Invalid Client |