tencent cloud

LLM Service TokenHub

Audio Separate API Guide

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-30 19:32:34
Diterjemahkan oleh AI

Overview

Tencent Cloud WAND is Tencent Cloud's audio and video AI brand. Its model foundation integrates self-developed vertical AI models and mainstream SOTA models, with deep engineering optimization, and has accumulated over 100 AI applications and industry solutions, covering capabilities such as multimodal generation, understanding, audio, codecs, image quality enhancement, and erasure. Audio Separate is built on WAND-Vega-Audio. It intelligently separates vocals and background sound (including accompaniment) from audio and video, generating independent audio materials for dubbing and translation, accompaniment extraction, and secondary creation. It is suitable for scenarios such as short drama global expansion, music covers, and video remixing.
Note:
This API uses asynchronous calls: a task_id is returned immediately after a task is submitted, and you need to poll the query API to obtain the processing result. A single task produces one selected audio track. To obtain multiple types of audio tracks, submit tasks separately.

Prerequisites

You have registered a Tencent Cloud account and activated the TokenHub service.
You have obtained the API Key in the TokenHub console.
Note:
In all examples below, YOUR_API_KEY must be replaced with your own API Key. The authentication method is the request header Authorization: Bearer YOUR_API_KEY.

Call Process

1. To submit a task: call the "Initiate Vocal and Background Sound Separation Task" API, which returns a task_id upon success.
2. To query the result: call the "Query Task Result" API with the task_id until the status is completed, and obtain the result audio URL from output.file_url.

Starting a Audio Separate Task

1. API Description

Perform audio track separation on the input audio, and retain the target track according to track. The input supports audio files, and videos with audio tracks can also be directly passed in.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/audio-separate

2. Input Parameters

Parameter Name
Required
Type
Description
audio_url
Yes (mutually exclusive with video_url)
string
Enter the audio URL. http(s) public network URLs or data:audio/...;base64,... format are supported.
video_url
No (mutually exclusive with audio_url)
string
Enter the video URL to directly process videos with audio tracks. If both audio_url and video_url are passed, video_url takes precedence.
track
Yes
array of string
Output track. Vocal: vocals (or singing); Background: background sound (or accompaniment); Sound: sound effects (Normal scenes only).
scene
No
string
Content scene. Normal (default): vocal and background sound separation; Music: vocal and accompaniment separation.
container
No
string
Output container format. m4a (default) / mp3 / flac / ogg.
codec
No
string
Output audio codec. aac (default) / mp3 / flac / ac3.
sample_rate
No
integer
Output sample rate. 44100 (default) / 32000 / 48000.

3. Sample Request

Extract vocals:
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/audio-separate' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"audio_url": "https://example.mp3",
"container": "m4a",
"codec": "aac",
"sample_rate": 44100,
"track": ["Vocal"],
"scene": "Normal"
}'
Extract accompaniment from video:
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/audio-separate' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"video_url": "https://example.mp4",
"track": ["Background"],
"scene": "Music"
}'

4. Output Parameters

Parameter Name
Type
Description
task_id
string
Unique task identifier, used to poll the query API.
status
string
Task status.
request_id
string
Unique request identifier. Include it when troubleshooting issues.

5. Sample Response

{
"task_id": "1400000001-procedurev2-xxxxxxxx",
"status": "queued",
"request_id": "9f1c0b7e-e024-426a-bb00-839553cb58c9"
}

Querying the Task Result

1. API Description

Query the execution status and output of a vocal and background sound separation task. After submission, poll this API until the status is completed or failed.
API: GET https://tokenhub.tencentmaas.com/v1/wand/tool/audio-separate/tasks/{task_id}

2. Input Parameters

Parameter Name
Required
Type
Description
task_id
Yes
string
Path parameter. Task ID returned by the submission API, which must be passed in as is.

3. Sample Request

curl -X GET 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/tool/audio-separate/tasks/1400000001-procedurev2-xxxxxxxx' \\
-H 'Authorization: Bearer YOUR_API_KEY'

4. Output Parameters

Parameter Name
Type
Description
task_id
string
Unique task identifier.
status
string
Task status: queued / in_progress / completed / failed.
progress
integer
Processing progress, ranging from 0 to 100.
output
object
Result product, returned only when completed.
output.file_url
string
URL of the result audio, which can be directly downloaded or played.
error
object
Failure details, returned only when failed.
error.code
string
Error code. See "Unified error codes".
error.message
string
Error description, used for troubleshooting and not recommended for program logic judgment.
request_id
string
Unique request identifier. Include it when troubleshooting issues.

5. Sample Response

Success:
{
"task_id": "1400000001-procedurev2-xxxxxxxx",
"status": "completed",
"progress": 100,
"output": {
"file_url": "https://example.m4a"
},
"request_id": "5c93e410-e024-426a-bb00-839553cb58c9"
}
Failed:
{
"task_id": "1400000001-procedurev2-xxxxxxxx",
"status": "failed",
"progress": 100,
"error": {
"code": "InternalError",
"message": "internal error"
},
"request_id": "5c93e410-e024-426a-bb00-839553cb58c9"
}

Appendix

Unified Error Codes

The error body is unified as follows:
{"request_id": "9f1c0b7e-e024-426a-bb00-839553cb58c9", "error": {"message": "...", "type": "..."}}
HTTP
type
Meaning
400
invalid_request_error
Parameter error: audio_url / video_url is missing or mutually exclusive, track is missing or has an invalid value, scene / container / codec / sample_rate has an invalid enum value, JSON decoding failed, task_id has an invalid format, or the task does not exist. Correct the request based on message and retry.
401
invalid_api_key
The API Key is missing or invalid. Check the Authorization request header.
404
not_found
The request path does not exist. Check the path spelling.
405
method_not_allowed
The request method is not allowed. Use POST for submission and GET for query.
429
rate_limit_exceeded
QPS rate limiting has been triggered (20 QPS by default for submission and 100 QPS by default for query). Reduce the request frequency and retry.
429
quota_exceeded
The quota has been exhausted. Retry later or apply for a quota increase.
500
server_error
An internal server error has occurred. You can retry. If the issue persists, submit a ticket with the Request ID for troubleshooting.
When a task fails, the query API returns status: failed, and the values of error.code are as follows:
Error Code
Meaning
InvalidParameterValue
Invalid parameter value (for example, invalid track / scene values, incompatible encoding and container, or no available audio track in the source file). Check the input parameters.
InternalError
An internal server error has occurred. You can retry. If the issue persists, submit a ticket with the Request ID for troubleshooting.

FAQs

1. Which Should I Pass: audio_url or video_url?

Choose one of the two: to process an audio file, pass audio_url; to directly process a video with an audio track, pass video_url. If both are passed, video_url takes precedence.

2. What Is the Output Format? Will the Video Frames Be Preserved?

The output is a pure audio file without video frames. By default, it is encapsulated in m4a, encoded with aac, and has a sample rate of 44100.

3. What Are the Supported Values for container, codec, and sample_rate?

The container can be m4a (default), mp3, flac, or ogg. The codec must match the container: for m4a, the codec can be aac (default), mp3, or ac3; for mp3, the codec can be mp3; for flac, the codec can be flac; for ogg, the codec can be flac. The sample_rate can be 32000, 44100 (default), or 48000.

4. What Are the Supported Values for track?

The track parameter specifies the track to retain, which can be Vocal, Background, or Sound (supported only in the Normal scenario). The Normal scenario supports 5 combinations: ["Vocal"], ["Background"], ["Sound"], ["Background","Sound"] (remove vocals), and ["Vocal","Sound"] (remove background music). The Music scenario supports 2 combinations: ["Vocal"] and ["Background"].

5. Will the Generated Audio Link Expire?

The links will expire. The result links are temporary addresses valid for 24 hours. Make sure to download or transfer the files within 24 hours after the task succeeds, or the links will become invalid.

6. Can I Use the Same task_id for Repeated Queries?

Yes. The query API has no side effects.


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan