Audio Enhancement โ
This document is based on the official Tencent Cloud document Audio/Video Enhancement Integration and covers only the audio features.
It removes noise from the input audio and improves its quality. It supports voice noise removal, audio quality enhancement, and volume normalization. Audio separation is covered in a separate document, Audio Separation.
Supported Features โ
| Feature | Description |
|---|---|
| Voice noise removal | Removes background noise from speech to improve clarity |
| Audio quality enhancement | Improves the overall quality of the input audio |
| Volume normalization | Reduces volume variance across segments to maintain a consistent listening level |
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.
How It Works โ
Audio enhancement is built on transcoding. When you create an enhancement template, enable noise removal with EnhanceConfig.AudioEnhance, and specify the template ID in Definition when you submit the task. The following is an example of creating an enhancement template.
{
"Container": "m4a",
"Name": "audio-denoise",
"AudioTemplate": {
"Codec": "aac",
"Bitrate": 64
},
"EnhanceConfig": {
"AudioEnhance": {
"Denoise": {
"Switch": "ON"
}
}
}
}Request Parameters โ
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| InputInfo | Object | Required | {"Type":"URL","UrlInputInfo":{"Url":"https://example.com/audio.mp3"}} | Input media. Type is URL or COS |
| OutputStorage | Object | Required | {"Type":"COS","CosOutputStorage":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou"}} | Output storage |
| OutputDir | String | Optional | /output/audio/ | Output directory. Must start with / and end with / |
| MediaProcessTask.TranscodeTaskSet.N.Definition | Integer | Required | 100910 | Audio enhancement template ID. Preset or custom template |
| MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.Container | String | Optional | m4a | Output container. Use m4a for audio-only output |
| MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.Codec | String | Optional | aac | Output audio codec |
| MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.Bitrate | Integer | Optional | 64 | Output audio bitrate (kbps) |
| MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.SampleRate | Integer | Optional | 44100 | Output sample rate (Hz) |
| MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.AudioChannel | Integer | Optional | 2 | Number of output channels |
| TaskNotifyConfig.NotifyUrl | String | Optional | https://example.com/callback | Task completion callback URL. NotifyType is URL |
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))
params = {
"InputInfo": {
"Type": "URL",
"UrlInputInfo": {"Url": "https://example.com/audio.mp3"}
},
"OutputStorage": {
"Type": "COS",
"CosOutputStorage": {"Bucket": "mybucket-125xxx", "Region": "ap-guangzhou"}
},
"OutputDir": "/output/audio/",
"MediaProcessTask": {
"TranscodeTaskSet": [{
"Definition": 100910,
"OverrideParameter": {
"Container": "m4a",
"AudioTemplate": {
"Codec": "aac",
"Bitrate": 64,
"SampleRate": 44100,
"AudioChannel": 2
}
}
}]
}
}
req = models.ProcessMediaRequest
req.from_json_string(json.dumps(params))
resp = client.ProcessMedia(req)
print(resp.to_json_string)Response Example โ
{
"TaskId": "24000022-ScheduleTask-774f101xxxxxxx1tt110253",
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}Usage Notes โ
Because audio enhancement is built on transcoding, a single enhancement task is charged both an enhancement fee and a transcoding fee.
If you need audio separation, see Audio Separation. It uses the same pipeline as enabling the separation feature in an enhancement template.