Music Identification โ
This document refers to the Tencent Cloud official document Music Identification Integration.
It identifies music in the input audio or video and recognizes cover songs. Based on Tencent Music's audio fingerprint algorithm, it returns the song title, album, artist, and playback segment.
API Information โ
| Item | Value |
|---|---|
| Service | MPS |
| API Action | ProcessMedia |
| Endpoint | mps.tencentcloudapi.com |
| API Version | 2019-06-12 |
| Processing method | 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 how to generate the signature, refer to the TokenHub document in Quick Start.
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/music/ | Output directory |
| AiAnalysisTask.Definition | Integer | Required | 21 | Music identification preset template ID. Fixed value 21 |
| AiAnalysisTask.ExtendedParameter | String | Required | {"tag":{"process_type":"1102"}} | Extended parameter. process_type is fixed to 1102 |
| 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/music/",
"AiAnalysisTask": {
"Definition": 21,
"ExtendedParameter": json.dumps({"tag": {"process_type": "1102"}})
},
"TaskNotifyConfig": {
"NotifyType": "URL",
"NotifyUrl": "https://example.com/callback"
}
}
req = models.ProcessMediaRequest
req.from_json_string(json.dumps(params))
resp = client.ProcessMedia(req)
print(resp.to_json_string)Response Example โ
The result is confirmed in the AiAnalysisResultSet of the completion callback via TagTask.Output.TagSet.
{
"AiAnalysisResultSet": [
{
"TagTask": {
"Status": "SUCCESS",
"Output": {
"TagSet": [
{
"Confidence": 100,
"Tag": "An Array of Stars",
"SpecialInfo": "{\"song_mid\":\"000Quzkn4N0CBN\",\"song_id\":521340020,\"reference_start\":30,\"song_name\":\"An Array of Stars\",\"album_name\":\"An Array of Stars\",\"reference_end\":255,\"singer_name\":\"TIA RAY\",\"segment_list\":[[30,165],[180,255]],\"other_singer_list\":[{\"singer_name\":\"Jam Hsiao\"}]}"
}
]
}
},
"Type": "Tag"
}
]
}SpecialInfo Fields โ
| Field | Type | Description |
|---|---|---|
| song_name | string | Song title |
| album_name | string | Album name |
| singer_name | string | Artist name |
| other_singer_list | array | List of related artists |
| reference_start | int | Approximate start time of the song |
| reference_end | int | Approximate end time of the song |
| segment_list | array | List of time segments where the song appears |
Usage Notes โ
If TagSet is ``, it means no song was matched in that audio segment.
reference_start and reference_end are for reference. The actual segment is based on segment_list. The detection interval is 15 seconds, so the deviation from the actual song length is at most 15 seconds.
Music identification is billed based on the length of the input file.