Updated on 2025-12-08 GMT+08:00

Creating an Asynchronous TTS Task

Function

Generates an audio file.

Before using this API, you need to enable pay-per-use billing for TTS on the service overview page of the MetaStudio console.

To enable pay-per-use billing, click Enable on the TTS card. In the displayed dialog box, check the box indicating your agreement. Click OK.

To use a third-party voice for TTS, purchase a Mobvoi voice package. For details, see "Purchasing a Mobvoi Voice Package" in User Guide.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

URI

POST /v1/{project_id}/ttsc/async-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

No

String

User token. This parameter is mandatory when token authentication is used.

You can obtain the token by calling the IAM API used to obtain a user token.

Value of X-Subject-Token in the response header.

Authorization

No

String

Authentication information. This parameter is mandatory for AK/SK authentication.

X-Sdk-Date

No

String

Time when a request is sent. This parameter is mandatory for AK/SK authentication.

X-Project-Id

No

String

Project ID. This parameter is mandatory for AK/SK authentication.

X-App-UserId

No

String

Third-party user ID, which does not allow Chinese characters.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

text

Yes

String

Text to be composited

tts_text

No

String

Text to be sent for TTS

voice_asset_id

Yes

String

Timbre ID. For details about how to obtain a timbre ID, see Obtaining a Timbre ID.

speed

No

Integer

Speaking speed.

  • The value 100 indicates the normal speaking speed of an adult, which is about 250 words per minute.

  • 50 indicates 0.5x speaking speed, 100 indicates normal speaking speed, and 200 indicates 2x speaking speed.

Value range:

50~200

Default value:

100

pitch

No

Integer

Pitch.

Value range:

50~200

Default value:

100

volume

No

Integer

Volume.

Value range:

90~240

Default value:

140

audio_format

No

String

Output audio file format. The default value is WAV.

  • WAV

  • MP3

Default value:

WAV

need_timestamp

No

Boolean

Whether a timestamp needs returning. false: no; true: yes. Default value: false

Default value:

false

silence_flag

No

Boolean

Whether to return silent audio streams when an exception occurs.

Default value:

false

silence_time_ms

No

Integer

Duration of a silent audio stream returned when an exception occurs, in milliseconds.

Value range:

0~5000

Default value:

2000

callback_config

No

TtsCallBackConfig object

Callback settings.

gen_srt

No

Boolean

Whether to enable subtitling.

srt_len

No

Long

Maximum subtitle length.

Value range:

0~10000

srt_line_limit

No

Integer

Maximum number of subtitle lines. The default value is 1.

Value range:

0~5000

Default value:

1

slice_segments

No

Boolean

Whether to segment the text.

Default value:

true

channels

No

Integer

Audio channel (mono | stereo)

The value ranges from 1 to 2 and defaults to 1.

Value range:

1~2

Default value:

1

output_external_url

No

String

External URL for uploading an audio file.

NOTE:
  • You can upload an audio to an external URL only after being whitelisted.

srt_output_external_url

No

String

External URL for uploading a subtitle file.

NOTE:
  • You can upload a subtitle file to an external URL only after being whitelisted.

action_output_external_url

No

String

External URL for uploading an action information file.

NOTE:
  • You can upload an action information file to an external URL only after being whitelisted.

is_vocabulary_config_enable

No

Boolean

Whether to apply the pronunciation configuration of the current tenant.

is_concurrent_resource

No

Boolean

Whether to use yearly/monthly billing for concurrent resources.

priority

No

Integer

Priority (0–10). The value 0 indicates the highest priority. The default value is 5.

Value range:

0~10

Default value:

10

Table 4 TtsCallBackConfig

Parameter

Mandatory

Type

Description

callback_url

Yes

String

Callback URL.

The callback request body is in JSON format and contains the following parameters:

status: FINISHED, ERROR, or WAITING

job_id: task ID

audio_file_download_url: audio file path

subtitle_file_download_url: subtitle file path

audio_duration: audio duration (in seconds)

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

job_id

String

Task ID.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Return code.

  • MSS.000000001: failure

  • MSS.000000002: internal error

  • MSS.000000003: invalid parameter

  • MSS.000000004: invalid access. The access is not authenticated or fails to be authenticated.

error_msg

String

Return result description

request_id

String

Unique ID of the request.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Return code.

  • MSS.000000001: failure

  • MSS.000000002: internal error

  • MSS.000000003: invalid parameter

  • MSS.000000004: invalid access. The access is not authenticated or fails to be authenticated.

error_msg

String

Return result description

request_id

String

Unique ID of the request.

Example Requests

POST https://{endpoint}/v1/3f0924078d1b471c884a5383d4dec9fa/ttsc/async-jobs

{
  "text" : "Hello, everyone. I'm Sarah.",
  "voice_asset_id" : "c84054e7f29543048d585f61248c64c9"
}

Example Responses

Status code: 200

Succeeded.

{
  "job_id" : "26f06524-4f75-4b3a-a853-b649a21aaf66"
}

Status Codes

Status Code

Description

200

Succeeded.

400

Parameter error.

500

Server error.

Error Codes

See Error Codes.