Feature Introduction
Music recognition capability can analyze user-input songs through algorithms and output song-related information (artist name, song name). Currently only supports searching songs that have been added to the database (proprietary database contains 36,000+ popular songs)
API Description
Request Method: POST (HTTP)
Request URL: https://api.mediax.tencent.com/job
Request Header: Content-Type: application/json
Request Flow: The API includes 'Create Task' and 'Query Task'. After creating a task, users can actively query the task to know the result, or input a callback address when creating the task, and the task will automatically callback to that address after completion
Other Requirements: File format: 44100HZ sampling rate is recommended; common audio formats are recommended, such as mp3, wav
Create Task
Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| action | Yes | string | Common parameter, here is CreateJob |
| secretId | Yes | string | Common parameter, user SecretId |
| secretKey | Yes | string | Common parameter, user SecretKey |
| createJobRequest | Yes | object | |
| - inputs | Yes | Array of Input | Input, input structure array |
| - outputs | Yes | Array of Output | Output, output structure array |
| - callback | No | string | Callback address, default: callback disabled |
| - customId | No | string | User-defined task ID, less than 64 characters |
| - timeout | No | int | Task timeout, in seconds. Task will be set to ERROR after timeout |
Input
| Parameter | Required | Type | Description |
|---|---|---|---|
| url | No | string | Source URL address, choose one with source field |
| source | No | object | Repository source settings, choose one with url field |
| - contentId | Yes | string | Repository ID |
| - path | Yes | string | Source path |
Output
| Parameter | Required | Type | Description |
|---|---|---|---|
| inputSelectors | Yes | Array of int | Input source for this output |
| smartContentDescriptor | Yes | SmartContentDescriptor | Smart capability description, default: empty |
| - musicRecognition | Yes | object | Music recognition |
| -- outputNum | Yes | int | Number of prediction results to return. Range [1,5] |
Request Example:
{
"action": "CreateJob",
"secretId": "{secretId}",
"secretKey": "{secretKey}",
"createJobRequest": {
"customId": "{customId}",
"callback": "{callback}",
"inputs": [
{
"url": "{url}"
}
],
"outputs": [
{
"inputSelectors": [0],
"smartContentDescriptor": {
"musicRecognition": {
"outputNum": 1
}
}
}
]
}
}
Response Example:
{
"requestId": "ac004192-110b-46e3-ade8-4e449df84d60",
"createJobResponse": {
"job": {
"id": "13f342e4-6866-450e-b44e-3151431c578b",
"state": 1,
"customId": "{customId}",
"callback": "{callback}",
"inputs": [
{
"url": "{url}"
}
],
"outputs": [
{
"inputSelectors": [0],
"smartContentDescriptor": {
"musicRecognition": {
"outputNum": 1
}
}
}
],
"timing": {
"createdAt": "1603432763000",
"startedAt": "0",
"completedAt": "0"
}
}
}
}
State
| Value | Meaning |
|---|---|
| 1 | SUBMITTED |
| 2 | PROCESSING |
| 3 | COMPLETED |
| 4 | ERROR |
| 5 | CANCELED |
Get Task Information
In the music recognition capability, if the queried task is successful (state=3), the task's Output will carry a smartContentResult structure, in which the musicRecognition field (Array of MusicRecognitionResult) stores the music recognition results.
Response MusicRecognitionResult Field Description
| Parameter | Type | Description |
|---|---|---|
| name | string | Song name |
| artist | string | Artist name |
| offset | string | Position where the input segment appears in the original song, in seconds |
| confidence | string | Confidence |
1. Active Query, Based on User-Defined customId Passed When Creating Task Request Example:
{
"action": "ListJobs",
"secretId": "{secretId}",
"secretKey": "{secretKey}",
"listJobsRequest": {
"customId": "{customId}"
}
}
Response Example:
{
"requestId": "c9845a99-34e3-4b0f-80f5-f0a2a0ee8896",
"listJobsResponse": {
"jobs": [
{
"id": "a95e9d74-6602-4405-a3fc-6408a76bcc98",
"state": 3,
"customId": "{customId}",
"callback": "{callback}",
"timing": {
"createdAt": "1610513575000",
"startedAt": "1610513575000",
"completedAt": "1610513618000"
},
"inputs": [ { "url": "{url}" } ],
"outputs": [
{
"inputSelectors": [ 0 ],
"smartContentDescriptor": {
"musicRecognition": {
"outputNum": 1
}
}
"smartContentResult": {
"musicRecognition": [
{
"name":"Desperate Smile",
"artist":"Andy Lau",
"confidence":"0.31",
"offset":"101.98"
}
]
}
}
]
}
],
"total": 1
}
}
2. Active Query, Based on id in Response After Creating Task Request Example:
{
"action": "GetJob",
"secretId": "{secretId}",
"secretKey": "{secretKey}",
"getJobRequest": {
"id": "{id}"
}
}
Response Example:
{
"requestId": "c9845a99-34e3-4b0f-80f5-f0a2a0ee8896",
"getJobResponse": {
"job": {
"id": "a95e9d74-6602-4405-a3fc-6408a76bcc98",
"state": 3,
"customId": "{customId}",
"callback": "{callback}",
"timing": {
"createdAt": "1610513575000",
"startedAt": "1610513575000",
"completedAt": "1610513618000"
},
"inputs": [ { "url": "{url}" } ],
"outputs": [
{
"inputSelectors": [ 0 ],
"smartContentDescriptor": {
"musicRecognition": {
"outputNum": 1
}
}
"smartContentResult": {
"musicRecognition": [
{
"name":"Desperate Smile",
"artist":"Andy Lau",
"confidence":"0.31",
"offset":"101.98"
}
]
}
}
]
}
}
}