Skip to content

Music Identification โ€‹

Updated

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

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

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/music/Output directory
AiAnalysisTask.DefinitionIntegerRequired21Music identification preset template ID. Fixed value 21
AiAnalysisTask.ExtendedParameterStringRequired{"tag":{"process_type":"1102"}}Extended parameter. process_type is fixed to 1102
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/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.

json
{
  "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 โ€‹

FieldTypeDescription
song_namestringSong title
album_namestringAlbum name
singer_namestringArtist name
other_singer_listarrayList of related artists
reference_startintApproximate start time of the song
reference_endintApproximate end time of the song
segment_listarrayList 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.

Built with VitePress ยท Deployed on Tencent EdgeOne Pages