Audio Separation โ
This document refers to the official Tencent Cloud document Audio Separation Integration.
It separates the vocals (voice), accompaniment, and background sound from the input video or audio and outputs them as separate tracks. It runs on the same ProcessMedia pipeline as video quality enhancement and is enabled by the EnhanceConfig.AudioEnhance.Separate configuration.
API Information โ
| Item | Value |
|---|---|
| Service | MPS |
| API Action | ProcessMedia |
| Endpoint | mps.tencentcloudapi.com |
| API version | 2019-06-12 |
| Processing mode | Asynchronous (query the result after a TaskId is issued) |
Authentication is common to all API and uses the TC3-HMAC-SHA256 (SecretId/SecretKey) signature. For details on how to generate the signature, see the TokenHub document in Quick Start.
You can retrieve the result through DescribeTaskDetail or a completion callback.
Request Parameters โ
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| InputInfo | Object | Required | {"Type":"COS","CosInputInfo":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou","Object":"/input/video.mp4"}} | Input media information. Type is URL or COS |
| OutputStorage | Object | Optional | {"Type":"COS","CosOutputStorage":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou"}} | Output storage. Specify the COS Bucket and Region |
| OutputDir | String | Optional | /output/enhance/ | Output directory. Must start with / and end with / |
| MediaProcessTask.TranscodeTaskSet.N.RawParameter | Object | Required | See the call example below | Audio separation is supported only in custom parameter mode |
| RawParameter.EnhanceConfig.AudioEnhance.Separate.Switch | String | Required | ON | Enables audio separation |
| RawParameter.EnhanceConfig.AudioEnhance.Separate.Type | String | Required | normal | Separation type. normal (vocal/background separation) or music (accompaniment separation) |
| RawParameter.EnhanceConfig.AudioEnhance.Separate.Track | String | Required | vocal | Output track. vocal (voice) or background (background). Default value โ |
| RawParameter.Container | String | Optional | mp4 | Output container: mp4 / hls / flv |
| RawParameter.AudioTemplate.Codec | String | Optional | aac | Output audio codec: aac / mp3 / copy |
| RawParameter.AudioTemplate.Bitrate | Integer | Optional | 128 | Output audio bitrate (kbps) |
| TaskNotifyConfig.NotifyUrl | String | Optional | https://example.com/callback | Task completion callback URL. NotifyType is URL |
The separation targets and parameter combinations correspond as follows.
| Separation Target | Type | Track |
|---|---|---|
| Vocal extraction (removes background music) | normal | vocal |
| Background sound extraction (removes voice) | normal | background |
| Accompaniment extraction (removes voice, keeps music) | music | background |
Response Parameters โ
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| TaskId | String | Always | 1250017490-20260318152230-abcdef123456 | Issued task ID. Used to query the result |
| RequestId | String | Always | 3c140219-cfe9-470e-b241-907877d6fb03 | Request identifier |
Call Example โ
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.mps.v20190612 import mps_client, models
cred = credential.Credential("<SecretId>", "<SecretKey>")
http_profile = HttpProfile
http_profile.endpoint = "mps.tencentcloudapi.com"
client = mps_client.MpsClient(cred, "ap-guangzhou", ClientProfile(httpProfile=http_profile))
# Vocal extraction
params = {
"InputInfo": {
"Type": "URL",
"UrlInputInfo": {"Url": "https://example.com/video.mp4"}
},
"OutputStorage": {
"Type": "COS",
"CosOutputStorage": {"Bucket": "mybucket-125xxx", "Region": "ap-guangzhou"}
},
"OutputDir": "/output/enhance/",
"MediaProcessTask": {
"TranscodeTaskSet": [{
"RawParameter": {
"Container": "mp4",
"RemoveVideo": 0,
"RemoveAudio": 0,
"VideoTemplate": {
"Codec": "h265", "Fps": 0, "Bitrate": 0,
"Width": 1920, "Height": 0,
"ResolutionAdaptive": "open", "FillType": "black",
"ScenarioBased": 1, "CompressType": "standard_compress"
},
"AudioTemplate": {
"Codec": "aac", "Bitrate": 128,
"SampleRate": 44100, "AudioChannel": 2
},
"TEHDConfig": {"Type": "TEHD-100", "MaxVideoBitrate": 0},
"EnhanceConfig": {
"AudioEnhance": {
"Separate": {"Switch": "ON", "Type": "normal", "Track": "vocal"}
}
}
}
}]
}
}
req = models.ProcessMediaRequest
req.from_json_string(json.dumps(params))
resp = client.ProcessMedia(req)
print(resp.to_json_string)Response Example โ
{
"TaskId": "1250017490-20260318152230-abcdef123456",
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}Usage Notes โ
For Separate.Track, specify vocal for vocal extraction and background for background sound extraction.
Audio separation and video quality enhancement each consist of their own task.
If you need both vocals and accompaniment, submit two tasks with different Separate configurations. To query the results, use DescribeTaskDetail in Task Query.