Audio moderation aims to identify malicious information in audio contents, and give the moderation result and handling suggestions.
The caller submits an audio clip for moderation, and specifies the detection type. The server processes the data and returns the detection result by callback.
Compared with the synchronous moderation API, the asynchronous API can receive more processing data, thus consuming more time.
The currently available detection types include: moan recognition and sensitive word recognition.
Detection types and their labels are listed below:
Detection Type | Description | Action | Label |
---|---|---|---|
Moan recognition | Detect voiceprint features in audio files, and recognize illegal features, such as moan | porn | normal: normal moan: moan |
Sensitive word recognition | Translate the text of audio files, and recognize sensitive and illegal contents | antispam | normal: normal terrorism: terrorism porn: porn illegal: illegal politics: politically sensitive contents abuse: abuse ad: advertisement cheating feudalism: feudalism religion: religiously sensitive contents affairs: affairs contraband: contraband minors: minors banned-website: banned websites |
Automatic speech recognition | Translate the text of audio files | asr | normal: normal |
Restriction Category | Description |
---|---|
File source | Audio URL starting with HTTP/HTTPS |
File duration | The maximum duration is 5 minutes by default. For Longer duration of audio files, contact customer support. |
File size | No more than 50MB for a single audio file |
File format | Support aac, mp3, m4a, and mp4. For more formats, contact customer support. |
Language support | Support sensitive word recognition (Chinese and Bahasa Indonesia). For more language support, contact customer support. |
Concurrency restriction | You can submit up to 20 audio clips for moderation per second, and the system processes up to 200 audio clips concurrently. For a higher concurrency, contact customer support. |
Area restriction | Only in Chinese mainland. For support in other countries and regions, contact customer support. |
Result cache | After the server complete processing, the result will be cached for 2 hours for the caller's search, and automatically removed after 2 hours. |
Send a moderation request using HTTP POST
Item | Description |
---|---|
Request method | POST |
Request protocol | HTTPS |
Request domain name | ai.jocloud.com |
Request path | app/{appid}/v1/audio/async/submit?traceId=uuid-xxxx-xxxx-xxxx-xxxx |
Request parameters | traceId is a uuid string, and used for problem positioning during troubleshooting. It is suggested to use different values for each request. |
Request header | Content-Type: application/json;charset=UTF-8 token: authentication token; see its generation method in Identity Authentication |
Request Body | json character string, defined as follows |
Table: body data structure
Name | Type | Required | Description |
---|---|---|---|
actions | String array | Yes | Detection type. Options include: - porn: moan recognition - antispam: sensitive word recognition - asr: automatic speech recognition |
data[] | JSON array | Yes | Specify the detection object information list. Each element in the JSON array is a sound detection object structure (see the request data table below). A single request can process up to 5 audio clips. |
callback | String | No | Result callback path, supporting HTTP/HTTPS callback. Allow null. When it is null, you can obtain the detection result through search APIs. |
sequence | String | No | This value is used for the signature in the callback notification request. This field is mandatory for callback. See details about the application method in the description on callback of detection results. |
Table: request data
Name | Type | Required | Description |
---|---|---|---|
dataId | String | Yes | Object unique identifier, for example: uuid-xxxx-xxxx-xxxx-xxxx |
dataType | String | Yes | Data type - URL: URL starting with HTTP/HTTPS |
content | String | Yes | URL of an audio clip to be detected |
context | JSON | No | Customized context data, automatically provided when a result is returned. |
extra | JSON | No | Extra configure. See the extra table below. |
Table: extra
Name | Type | Description |
---|---|---|
lang | String | Language of the audio clip. -chinese: Chinese -bahasa: Bahasa Indonesia |
The response content is a json object, as defined below
Name | Type | Required | Description |
---|---|---|---|
code | Integer | Yes | Error code. See the description of error codes below |
message | String | Yes | Error Message description |
traceId | String | Yes | Map to traceId in the request parameter |
requestId | String | Yes | The unique request ID generated by the system for this request, Used for Subsequent Result Callback and Status Search. |
timestamp | Integer | Yes | Current unix timestamp (s) |
Upon completion of processing, the server will return the result to the caller through the callback address entered for the call.
Callback Method : HTTPS post
Callback Path : the callback address entered when submitting for detection
Callback Header : add a checksum to the header to verify the content validity, so as to prevent result tampering.
The checksum string is generated by the following method:
When submitting for detection, combine parameter "subsequence" and result "body" into a string, and generate checksum with the SHA256 algorithm.
Callback Content : HTTP body is a json object, defined as follows
Name | Type | Required | Description |
---|---|---|---|
code | Integer | Yes | Error code. See the description of error codes below |
message | String | Yes | Error message description |
traceId | String | Yes | traceId content in the pass-through request parameter |
requestId | String | Yes | The system generates a unique task identifier specific to this detection request |
timestamp | Integer | Yes | Current unix timestamp (s) |
data[] | JSON array | No | Detection result data list (for specific structure, see the table of returned data below). Each item in the array represents a processing result of one data, and this field may be empty in case of errors. |
Name | Type | Required | Description |
---|---|---|---|
code | Integer | Yes | Error code. See the description of error codes, Error code in data and action |
message | String | Yes | Description of errors |
dataId | String | Yes | Map to dataId in the request |
taskId | String | Yes | A unique task identifier generated for multiple detection types of this detection object |
context | JSON | No | Map to context in the request |
results[] | JSON array | No | Return the result data. When the callback succeeds (code==200), the return result contains one or more elements. Each element represents the processing result of one action, and its specific structure is shown in the "result" table below. |
Name | Type | Required | Description |
---|---|---|---|
code | Integer | Yes | Error code. See the description of error codes, Error code in data and action |
message | String | Yes | Description of errors |
action | String | Yes | Detection type, mapping to the detection type (actions) in the call request |
label | String | Yes | Detection result label; its value is related to action. For specific values, see above moderation types and corresponding label specification table |
rate | Floating-point number | Yes | Probability of detection result label, with the value ranging between [0.00 – 1.00]. The larger the value, the higher the credibility. |
suggestion | String | Yes | Operation recommended, with the value options: - pass: normal, requiring no operation; - block: illegal, suggested to give punishment on illegal contents; - review: suspected; the detection result is uncertain and requires further manual moderation. |
duration | Floating-point number | Yes | Play duration of voice data |
text | String | No | Contents of transliteration text |
segment[] | JSON array | No | 'review' and 'block' audio segment identification result list. Different actions correspond to different segment parameters, see the definition of each action segment below for details |
Name | Type | Required | Description |
---|---|---|---|
begin | Floating-point number | No | Start time of audio clip (s) |
end | Floating-point number | No | End time of audio clip (s) |
score | Floating-point number | No | Matching degree of moan, value ranging between:[0–100]. The higher the score, the higher the matching degree. |
Name | Type | Required | Description |
---|---|---|---|
begin | Floating-point number | No | Start time of audio clips (s) |
end | Floating-point number | No | End time of audio clips (s) |
extraData[] | JSON array | No | The sensitive word recognition result list of this audio segment, the element structure is shown below antispam-extraData |
Table: antispam-extraData
Name | Type | Required | Description |
---|---|---|---|
hint | Json array | No | Hit keyword |
label | String | No | Type of hit keyword |
rate | Floating-point number | No | Meaningless, always "1.0" |
Upon completion of processing, the server will call back using the callback method. It is recommended to receive the processing result with the callback method. If necessary, the caller can obtain the processing status and result via searching following APIs.
Item | Description |
---|---|
Request method | GET |
Request protocol | HTTPS |
Request domain Name | ai.jocloud.com |
Request path | app/{appid}/v1/audio/async/results?traceId=uuid-xxxx-xxxx-xxxx-xxxx&requestId=yyyy |
Request parameters | traceId is a uuid string, used for problem positioning during troubleshooting. It is suggested to use different values for each request. requestId is the request ID to be searched, i.e. the requestId returned in the return result of the task submitted for detection. |
Request header | Content-Type: application/json;charset=UTF-8 token: Authentication token; see its generation method in Identity Authentication |
The response content is a json object, as defined below
Name | Type | Required | Description |
---|---|---|---|
code | Integer | Yes | Error code, consistent with HTTP status code and also subject to extension - 2xx indicates success - 4xx indicates request error - 500 indicates server error For specific values, see related descriptions. |
message | String | Yes | Error message description |
traceId | String | Yes | traceId content in the pass-through request parameter |
requestId | String | Yes | RequestId for the current search, consistent with the request parameter |
status | String | Yes | Task status (received-pending, processing-in progress, completed-done) |
timestamp | Integer | Yes | Current unix timestamp (s) |
data[] | Array | No | Return the result data. When it's successfully called (code==200), see the above Table: data for element definition. |
# -*- coding: utf-8 -*-
#! python3.5
import requests
import uuid
import base64
host = "https://ai.jocloud.com"
appid = 123456789 # Your service ID
restful_id = '********************' # Your certificate ID
restful_secret = '********************' # Your certificate key
traceid = str(uuid.uuid4())
dataid = str(uuid.uuid4())
# url
url = host + '/app/%s/v1/audio/async/submit?traceId=%s' % (appid, traceid)
callback = 'http://127.0.0.1/check?dataid=%s' % dataid
# headers
headers = {
"content-type": "application/json"
}
auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()
# content
values = {
'actions': ['porn'],
'data': [
{
'dataType': 'URL',
'content': 'http://static.s3.huajiao.com/Object.access/hj-video/NjJhYWU0OTZmOTY5ZDZkM2UxZDBjZDE0MWNkMjljMDcubXAz',
'dataId': dataid,
'context': {'uid': 12345}
}
],
'callback': callback,
'sequence': 'test'
}
# request
res = requests.post(url, json=values, headers=headers)
print('code=%s, data=%s\n' % (res.status_code, res.text))
Respond to a request
{
"code": 200,
"message": "OK",
"traceId": "ff1ec05d-46e7-4235-9c46-cd44b684f043",
"requestId": "d9f3171b-bd1f-48b1-b663-b232e4ed156b",
"timestamp": 1584088487
}
Initiate a search
# -*- coding: utf-8 -*-
#! python3.5
import requests
import uuid
import base64
host = "https://ai.jocloud.com"
appid = 123456789 # Your service ID
restful_id = '********************' # Your certificate ID
restful_secret = '********************' # Your certificate key
requestId = 'd9f3171b-bd1f-48b1-b663-b232e4ed156b'# Fill in the requestId carried in the Response of the detection request
traceid = str(uuid.uuid4())
dataid = str(uuid.uuid4())
# url
url = host + '/app/%s/v1/audio/async/results?traceId=%s&requestId=%s' % (appid, traceid, requestId)
# headers
headers = {
"content-type": "application/json"
}
auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + auth.decode()
# request
res = requests.get(url, headers=headers)
print('code=%s, data=%s\n' % (res.status_code, res.text))
Respond to a request
{
"code": 200,
"data": [
{
"code": 200,
"message": "OK",
"context": { "uid": 12345 },
"dataId": "69c5b065-d0bf-47c5-84cc-252f6dbf6979",
"results": [
{
"code": 200,
"message": "OK",
"action": "porn",
"label": "moan",
"rate": 0.7400000095367432,
"suggestion": "review",
"duration": 10,
"segment": [
{
"begin": 0,
"end": 10,
"score": 74
}
]
}
],
"taskId": "36c1f70f-89ae-47c3-ba97-40b0a82af7d7"
}
],
"message": "OK",
"requestId": "d9f3171b-bd1f-48b1-b663-b232e4ed156b",
"status": "completed",
"timestamp": 1584088487,
"traceId": "f257b637-692c-4033-85aa-ad2ebbc50a89"
}
Version | Time | Description |
---|---|---|
V1.1.0 | 2020-10-14 | Add 'asr' action support |
V1.0.1 | 2020-07-24 | Add Bahasa Indonesia language support |
V1.0.0 | 2020-03-13 | Initial version |