Help Center/ Content Moderation/ API Reference/ APIs/ Audio Moderation/ Creating an Audio Moderation Job
Updated on 2024-11-04 GMT+08:00

Creating an Audio Moderation Job

Function

This API is used to create an audio moderation job. After the job is created, the job ID is returned.

URI

POST /v3/{project_id}/moderation/audio/jobs

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token, which can be obtained by calling the IAM API (The token is the value of X-Subject-Token in the response header.)

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

data

Yes

AudioInputBody object

Audio data input

event_type

No

String

Event type. The options are as follows:

  • default: default event
  • audiobook: audio book
  • education: educational audio
  • game: game voice room
  • live: livestream fashion show
  • ecommerce: livestream e-commerce
  • voiceroom: dating voice room
  • private: private voice chat

categories

No

Array of strings

Types of risks to be detected. The list cannot be empty.

The risk types are as follows:

  • porn
  • ad
  • moan
  • abuse

callback

No

String

If this field is not empty, the callback will be invoked to send the detection result to your URL. If this field is empty, you need to perform polling periodically to obtain the detection result.

NOTE:
  1. Your callback interface must support the POST method.
  2. For details about the callback data format, see the example response for the API used to query an audio moderation job.
  3. If the callback interface of your server returns HTTP status code 200 within three seconds after receiving the result from the content security service, the result is successfully received. If another HTTP status code is returned or no status code is returned within three seconds, the result fails to be received. In this case, the content security service will send the detection result repeatedly.

biz_type

No

String

Name of a custom moderation policy created on the console.

  • If biz_type is specified in the request, biz_type is preferentially used. Parameters event_type and categories do not take effect. The review policy is determined by the biz_type.
  • If biz_type is not transferred, event_type and categories must be transferred.
NOTE:

This parameter is unavailable in the AP-Singapore region.

seed

No

String

Used to verify the requests initiated by Huawei Cloud content security service during callback notifications. You can customize it. The value is a random string that contains a maximum of 64 characters, including letters, digits, and underscores (_).

NOTE:

If seed is not empty, headers contains the X-Auth-Signature field. The field value is generated using the HMAC-SHA256 algorithm. The string to be encrypted is composed of create_time, job_id, request_id, and seed in sequence. The key is seed.

Table 4 AudioInputBody

Parameter

Mandatory

Type

Description

url

Yes

String

Audio URL

language

No

String

Supported audio language. The options are as follows:

  • zh: Chinese (default value)
  • en: English
  • ar: Arabic

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Unique ID of the request, which is used for troubleshooting. You are advised to save the ID.

Minimum length: 2

Maximum length: 64

job_id

String

Unique job ID

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Error message of a failed API call.

This parameter is not included when the API is successfully called.

Example Request

endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.

For example, if the service is deployed in the CN North-Beijing4 region, the endpoint is moderation.cn-north-4.myhuaweicloud.com and the request URL is https://moderation.cn-north-4.myhuaweicloud.com/v3/{project_id}/moderation/audio/jobs. For details about how to obtain the project ID, see Obtaining a Project ID.

Create a default audio moderation job with event_type set to default to detect pornographic content and advertisements.

POST https://{endpoint}/v3/{project_id}/moderation/audio/jobs

{
  "data" : {
    "url" : "https://xxxxx.wav"
  },
  "event_type" : "default",
  "categories" : [ "porn", "ad" ],
  "callback" : "http://xxxx"
}

Example Response

Status code: 200

Example of a successful response

{
  "job_id" : "01661356800_7c0fe871f80543358917e4faebca4a48",
  "request_id" : "07490f57ac5e034c077ab25b5f9e1da5"
}

Status code: 400

Example of a failed response

{
    "error_code": "AIS.0401",
    "error_msg": "The input parameter event_type is incorrect."
}

Status Codes

Status Code

Description

200

Example of a successful response

400

Example of a failed response

Error Codes

For details, see Error Codes.