Skip to content

Audio Separation โ€‹

Updated

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 โ€‹

ItemValue
ServiceMPS
API ActionProcessMedia
Endpointmps.tencentcloudapi.com
API version2019-06-12
Processing modeAsynchronous (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 โ€‹

ParameterTypeRequiredExampleDescription
InputInfoObjectRequired{"Type":"COS","CosInputInfo":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou","Object":"/input/video.mp4"}}Input media information. Type is URL or COS
OutputStorageObjectOptional{"Type":"COS","CosOutputStorage":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou"}}Output storage. Specify the COS Bucket and Region
OutputDirStringOptional/output/enhance/Output directory. Must start with / and end with /
MediaProcessTask.TranscodeTaskSet.N.RawParameterObjectRequiredSee the call example belowAudio separation is supported only in custom parameter mode
RawParameter.EnhanceConfig.AudioEnhance.Separate.SwitchStringRequiredONEnables audio separation
RawParameter.EnhanceConfig.AudioEnhance.Separate.TypeStringRequirednormalSeparation type. normal (vocal/background separation) or music (accompaniment separation)
RawParameter.EnhanceConfig.AudioEnhance.Separate.TrackStringRequiredvocalOutput track. vocal (voice) or background (background). Default value โ€”
RawParameter.ContainerStringOptionalmp4Output container: mp4 / hls / flv
RawParameter.AudioTemplate.CodecStringOptionalaacOutput audio codec: aac / mp3 / copy
RawParameter.AudioTemplate.BitrateIntegerOptional128Output audio bitrate (kbps)
TaskNotifyConfig.NotifyUrlStringOptionalhttps://example.com/callbackTask completion callback URL. NotifyType is URL

The separation targets and parameter combinations correspond as follows.

Separation TargetTypeTrack
Vocal extraction (removes background music)normalvocal
Background sound extraction (removes voice)normalbackground
Accompaniment extraction (removes voice, keeps music)musicbackground

Response Parameters โ€‹

ParameterTypeRequiredExampleDescription
TaskIdStringAlways1250017490-20260318152230-abcdef123456Issued task ID. Used to query the result
RequestIdStringAlways3c140219-cfe9-470e-b241-907877d6fb03Request identifier

Call Example โ€‹

python
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 โ€‹

json
{
  "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.

Built with VitePress ยท Deployed on Tencent EdgeOne Pages