Skip to content

Audio Enhancement โ€‹

Updated

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

FeatureDescription
Voice noise removalRemoves background noise from speech to improve clarity
Audio quality enhancementImproves the overall quality of the input audio
Volume normalizationReduces volume variance across segments to maintain a consistent listening level

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.

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.

json
{
  "Container": "m4a",
  "Name": "audio-denoise",
  "AudioTemplate": {
    "Codec": "aac",
    "Bitrate": 64
  },
  "EnhanceConfig": {
    "AudioEnhance": {
      "Denoise": {
        "Switch": "ON"
      }
    }
  }
}

Request Parameters โ€‹

ParameterTypeRequiredExampleDescription
InputInfoObjectRequired{"Type":"URL","UrlInputInfo":{"Url":"https://example.com/audio.mp3"}}Input media. Type is URL or COS
OutputStorageObjectRequired{"Type":"COS","CosOutputStorage":{"Bucket":"mybucket-125xxx","Region":"ap-guangzhou"}}Output storage
OutputDirStringOptional/output/audio/Output directory. Must start with / and end with /
MediaProcessTask.TranscodeTaskSet.N.DefinitionIntegerRequired100910Audio enhancement template ID. Preset or custom template
MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.ContainerStringOptionalm4aOutput container. Use m4a for audio-only output
MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.CodecStringOptionalaacOutput audio codec
MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.BitrateIntegerOptional64Output audio bitrate (kbps)
MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.SampleRateIntegerOptional44100Output sample rate (Hz)
MediaProcessTask.TranscodeTaskSet.N.OverrideParameter.AudioTemplate.AudioChannelIntegerOptional2Number of output channels
TaskNotifyConfig.NotifyUrlStringOptionalhttps://example.com/callbackTask completion callback URL. NotifyType is URL

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))

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

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

Built with VitePress ยท Deployed on Tencent EdgeOne Pages