Music Recognition

功能介绍

听歌识曲能力,可以将用户输入的歌曲经过算法分析输出歌曲相关信息(歌手名称、歌曲名称)。目前只支持检索已入库的歌曲(自有曲库入库热门歌曲 3.6 万+)

接口说明

请求方式: POST(HTTP)

请求地址: http://service-mqk0mc83-1257411467.bj.apigw.tencentcs.com/release/job

请求头: Content-Type: application/json

请求流程: 接口包括‘创建任务’,‘查询任务’。创建任务后,用户可以主动查询任务来知晓任务结果,也可以在创建任务时输入回调地址(callback),则任务在完成后会自动回调该地址

其他要求: 文件格式:建议采用 44100HZ 采样率;建议采用常见音频格式,如 mp3、wav

创建任务

参数说明

参数 是否必选 类型 说明
action string 公共参数,此处为 CreateJob
secretId string 公共参数,用户 SecretId
secretKey string 公共参数,用户 secretKey
createJobRequest object
- inputs Array of Input Input,输入结构体数组
- outputs Array of Output Output,输出结构体数组
- callback string 回调地址,默认:不开启回调
- customId string 用户自定义任务 ID,小于 64 字符
- timeout int 任务超时时间,单位秒。超过超时时间后任务会被置为 ERROR

Input

参数 是否必选 类型 说明
url string 源 url 地址,与 source 字段二选一填写
source object 仓库源设置,与 url 字段二选一填写
- contentId string 仓库 ID
- path string 源路径

Output

参数 是否必选 类型 说明
inputSelectors Array of int 该输出的输入源
smartContentDescriptor SmartContentDescriptor 智能能力的描述,默认:空
- musicRecognition object 听歌识曲
-- outputNum int 返回预测结果个数。取值范围[1,5]

请求示例:

{
  "action": "CreateJob",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "createJobRequest": {
    "customId": "{customId}",
    "callback": "{callback}",
    "inputs": [
      {
        "url": "{url}"
      }
    ],
    "outputs": [
      {
        "inputSelectors": [0],
        "smartContentDescriptor": {
          "musicRecognition": {
            "outputNum": 1
          }
        }
      }
    ]
  }
}

返回示例:

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

含义
1 SUBMITTED
2 PROCESSING
3 COMPLETED
4 ERROR
5 CANCELED

获取任务信息

在听歌识曲能力中,如果查询到的任务成功(state=3),则任务的 Output 中会携带 smartContentResult 结构体,其中的 musicRecognition 字段(Array of MusicRecognitionResult),存储听歌识曲的结果。

返回 MusicRecognitionResult 字段说明

参数 类型 说明
name string 歌曲名称
artist string 歌手名称
offset string 输入片段在原曲中出现的位置,单位:秒
confidence string 置信度

1. 主动查询,根据用户在新建任务时传入的自定义 customId 请求示例:

{
  "action": "ListJobs",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "listJobsRequest": {
    "customId": "{customId}"
  }
}

返回示例:

{
    "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":"绝望的笑容",
                                    "artist":"刘德华",
                                    "confidence":"0.31",
                                    "offset":"101.98"
                                }
                           ]
                        }
                    }
                ]
            }
        ],
        "total": 1
    }
}

2. 主动查询,根据新建任务时回包带的 id 请求示例:

{
  "action": "GetJob",
  "secretId": "{secretId}",
  "secretKey": "{secretKey}",
  "getJobRequest": {
    "id": "{id}"
  }
}

返回示例:

{
    "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":"绝望的笑容",
                                    "artist":"刘德华",
                                    "confidence":"0.31",
                                    "offset":"101.98"
                                }
                           ]
                    }
                }
            ]
        }
    }
}
Tencent Media Lab
/
We would like to use performance and analytics cookies (“Cookies”) to help us recognize whether you are a returning visitor and to track the number of website views and visits. For more information about the Cookies we use and your options (including how to change your preferences) see our Cookies Policy.