💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 3.5.3 音乐点播 #### (1) 功能说明 音乐点播技能插件,支持按歌手、歌名、流派、场景、心情等点播音乐,返回最多包含20首歌曲的播放列表。目前音乐技能的数据主要融合网易和虾米音乐,客户可根据需求优先选择特定数据源。 #### (2) 接口说明 **请求方法** * POST **请求地址** * [http://api.ruyi.ai/v1/message](http://api.ruyi.ai/v1/message) **请求参数说明** | 参数名 | 参数类型 | 是否必须 | 参数说明 | | :--- | :--- | :---: | :--- | | q | String | 是 | 自然语言表达,例如“我要听五月天的歌”,"给我放首歌"等 | | app\_key | String | 是 | 应用开发者秘钥,注册开发者后台账号,建立虚拟助理后获得 | | user\_id | String | 是 | 用户唯一标识,便于支持个性化语义解析。建议开发者使用 UUID 字符,且不同用户必须用不同的 user\_id,防止意图串。 | #### (3) 返回说明 **返回参数说明** | 名称 | 类型 | 说明 | | :--- | :--- | :--- | | code | Integer | 返回代码 | | msg | String | 返回代码描述 | | parameters | JSON Object | 解析到的实体以及服务说明 | | action | String | 服务的接口名称 | | name | String | 匹配的意图名称 | | result | JSON Object | 接口返回内容 | | outputs | Array | 服务输出结果,微信端使用 type 类型为 wechat 开头的内容;硬件端收到所有内容,依据需求解析使用 | **返回代码说明** | 返回代码 | 错误类型 | 说明 | | :--- | :--- | :--- | | 0/200 | 成功 | 请求成功 | | 400 | 无效请求 | 某些必需参数缺失或参数值错误,详见msg字段 | | 401 | 未授权 | 授权失败,app\_key 缺失或错误 | | 403 | 请求被禁止 | 有效请求,但服务拒绝响应,请联系contact@ruyi.ai | | 408 | 请求超时 | 请求响应超时,一般响应时间设置为2000ms以内 | | 429 | 短时间内大量访问 | 短时间内请求数过多 | | 500 | 内部错误 | 服务处理异常 | | 503 | 服务不可用 | 服务异常或正在维护 | #### (4) 请求示例 **请求范例** _放首歌_ _我要听舒缓的歌_ _放一首告白气球_ _我要听刘德华_ _我想听凤凰传奇的最炫民族风_ _我要听王菲和陈奕迅合唱的歌_ _我要听摇滚乐_ _我要听王菲的但愿人长久;换个邓丽君唱的_ _有失恋的歌吗_ **请求示例** (成功,虾米资源,返回符合结果的20首歌的播放列表) * http://api.ruyi.ai/ruyi-api/v1/message?app\_key=APP\_KEY&user\_id=user0&q=我要听刘德华的忘情水 返回结果 ``` { "code": 0, "msg": "ok", "result": { "_text": "我要听刘德华的忘情水", "msg_id": "d140763a-fa95-4f71-97db-364f3bc31aba", "intents": [{ "parameters": { "musicGroupId1": "6e0d871e-5cba-313d-bc1f-f1fe92be74e0", "musicRecordingId": "e37a6b07-37d5-3437-93ee-6595be6690c3", "artistName1": "刘德华", "songName": "忘情水", "service": "music" }, "action": "歌手+歌曲", "name": "1-按歌手歌名组合点歌", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "music_list": [{ "name": "忘情水", "xiami": "23764", "image": "http://img.xiami.net/images/album/img3/175/5836abb2ed13d_8772903_1479977906_1.jpg", "artist": "刘德华" }, { "name": "不在意", "xiami": "36931", "image": "http://img.xiami.net/images/album/img48/648/30141322792371_1.jpg", "artist": "刘德华" }, { "name": "多愁善感", "xiami": "23788", "image": "http://img.xiami.net/images/album/img48/648/29051433392855_1.jpg", "artist": "刘德华" }, { "name": "小丑", "xiami": "1769816697", "image": "http://img.xiami.net/images/album/img48/648/4063301468225531_1.jpg", "artist": "刘德华" }, { "name": "魔鬼的门徒", "xiami": "24871", "image": "http://img.xiami.net/images/album/img48/648/29871412749089_1.jpg", "artist": "刘德华" }, { "name": "不能融化的冰", "xiami": "374811", "image": "http://img.xiami.net/images/album/img48/648/29581411699118_1.jpg", "artist": "刘德华" }, { "name": "迷惑", "xiami": "374787", "image": "http://img.xiami.net/images/album/img48/648/30181387538840_1.jpg", "artist": "刘德华" }, { "name": "忘情水[98新编重唱]", "xiami": "375063", "image": "http://img.xiami.net/images/album/img48/648/29471472451309_1.jpg", "artist": "刘德华" }, { "name": "为我鼓掌", "xiami": "24219", "image": "http://img.xiami.net/images/album/img48/648/29311425631717.jpeg", "artist": "刘德华" }, { "name": "亲爱的", "xiami": "1773925411", "image": "http://img.xiami.net/images/album/img48/648/19229652051422965205_1.jpg", "artist": "刘德华" }, { "name": "遗弃 ", "xiami": "374766", "image": "http://img.xiami.net/images/album/img48/648/30111387539451_1.jpg", "artist": "刘德华" }, { "name": "爱无知", "xiami": "24271", "image": "http://img.xiami.net/images/album/img48/648/29341436253893_1.jpg", "artist": "刘德华" }, { "name": "Rehearsal", "xiami": "374648", "image": "http://img.xiami.net/images/album/img48/648/29721413960446_1.jpg", "artist": "刘德华" }, { "name": "地球的心声", "xiami": "1769937740", "image": "http://img.xiami.net/images/album/img48/648/4063301468225531_1.jpg", "artist": "刘德华" }, { "name": "继续…", "xiami": "24396", "image": "http://img.xiami.net/images/album/img48/648/29421425631583.jpeg", "artist": "刘德华" }, { "name": "真我的风采 ", "xiami": "2127733", "image": "http://img.xiami.net/images/album/img69/7169/172202_1.jpg", "artist": "刘德华" }, { "name": "I Do", "xiami": "3518540", "image": "http://img.xiami.net/images/album/img48/648/3169191436253773_1.jpg", "artist": "刘德华,舒淇" }, { "name": "美人痛", "xiami": "374744", "image": "http://img.xiami.net/images/album/img66/48/58183788ef77e_2400066_1477982088_1.jpg", "artist": "刘德华" }, { "name": "Jenny 我不会", "xiami": "24589", "image": "http://img.xiami.net/images/album/img48/648/2960_1.jpg", "artist": "刘德华" }, { "name": "谁的心忘了收", "xiami": "1769638352", "image": "http://img.xiami.net/images/album/img48/648/29701425631561.jpeg", "artist": "刘德华" }], "msg": "ok" } }, "text": "为您播放【刘德华】的【忘情水】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "为您播放【刘德华】的【忘情水】" } }, { "type": "dialog", "property": { "text": "为您播放【刘德华】的【忘情水】", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "d6aac616-3f27-4eb1-aac8-7c6a74da976b" }], "meta_process_milliseconds": 168 } } ``` (成功,网易资源,返回符合结果的20首歌的播放列表) 返回结果 ``` { "code": 0, "msg": "ok", "result": { "_text": "我要听刘德华的忘情水", "msg_id": "8566056e-9984-4d23-976a-594526236eb3", "intents": [{ "parameters": { "musicGroupId1": "6e0d871e-5cba-313d-bc1f-f1fe92be74e0", "musicRecordingId": "e37a6b07-37d5-3437-93ee-6595be6690c3", "artistName1": "刘德华", "songName": "忘情水", "service": "music" }, "action": "歌手+歌曲", "name": "1-按歌手歌名组合点歌", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "music_list": [{ "name": "忘情水", "music163": "110740", "image": "http://p3.music.126.net/LRWWw0_d0wZWWicIKQIkfA==/65970697667341.jpg", "artist": "刘德华" }, { "name": "不在意", "music163": "113345", "image": "http://p4.music.126.net/l3v6oxxyCQlbXZHyuEZsGA==/706985976671979.jpg", "artist": "刘德华" }, { "name": "多愁善感", "music163": "27526253", "image": "http://p3.music.126.net/107iziz7elGtZbMja97XyQ==/5711962906359873.jpg", "artist": "刘德华" }, { "name": "小丑", "music163": "34586077", "image": "http://p4.music.126.net/eyYN9LMHq_0TH2mFuxr-zQ==/3289738790986243.jpg", "artist": "刘德华" }, { "name": "相依 相恋", "music163": "111937", "image": "http://p3.music.126.net/YA54XWfQ-2dYibsNSveHmQ==/119846767433327.jpg", "artist": "刘德华,陈嘉露" }, { "name": "魔鬼的门徒", "music163": "113196", "image": "http://p3.music.126.net/bdlQsBv3fOXvGMK-k90q5w==/79164837200574.jpg", "artist": "刘德华" }, { "name": "不能融化的冰", "music163": "111170", "image": "http://p3.music.126.net/-BHpBaApaUm1FysNhQq_Ww==/103354093016229.jpg", "artist": "刘德华" }, { "name": "ABCDE", "music163": "110810", "image": "http://p3.music.126.net/mm6rATcsvkRHygHxWZVcOQ==/50577534883053.jpg", "artist": "刘德华" }, { "name": "夏日FLESAT", "music163": "5256072", "image": "http://p3.music.126.net/TeoPnAtNwpoAIEZKt-BJ6w==/59373627916983.jpg", "artist": "刘德华" }, { "name": "如果看到她,请告诉我", "music163": "111423", "image": "http://p3.music.126.net/qJNREzavmwY8G3BI9RuuUg==/47278999999737.jpg", "artist": "刘德华" }, { "name": "もう一度抱きしめたい", "music163": "111185", "image": "http://p3.music.126.net/wdPv8mZiMeRXePK6nLys6Q==/111050674421867.jpg", "artist": "刘德华" }, { "name": "迷惑", "music163": "113516", "image": "http://p4.music.126.net/Uo6a2qSVGnSrvOG6DuSZZA==/631119674364613.jpg", "artist": "刘德华" }, { "name": "为我鼓掌", "music163": "110565", "image": "http://p3.music.126.net/05Lke1-JwDUiWDpKxOgMXg==/45079976739645.jpg", "artist": "刘德华" }, { "name": "亲爱的", "music163": "112995", "image": "http://p4.music.126.net/CqeHxFBf4mLt3Bir1kLZ0A==/61572651167502.jpg", "artist": "刘德华" }, { "name": "爱无知", "music163": "110601", "image": "http://p4.music.126.net/JvA2znldXq-Js_aWZyUBfA==/575044581338899.jpg", "artist": "刘德华" }, { "name": "Rehearsal", "music163": "111663", "image": "http://p4.music.126.net/4CCpQShTnW5jyjp0VL_6zA==/64871186051389.jpg", "artist": "刘德华" }, { "name": "地球的心声", "music163": "28152699", "image": "http://p4.music.126.net/fc2knfvhAOPRaxGWvnOo0g==/5770237022694259.jpg", "artist": "刘德华" }, { "name": "继续…", "music163": "110819", "image": "http://p3.music.126.net/mm6rATcsvkRHygHxWZVcOQ==/50577534883053.jpg", "artist": "刘德华" }, { "name": "再说一次.我爱你", "music163": "109688", "image": "http://p4.music.126.net/4LDKWEY3zgF5O65zNd8HHQ==/80264348840427.jpg", "artist": "刘德华" }, { "name": "I Do", "music163": "27591307", "image": "http://p4.music.126.net/KJ9054hIMgQZhhYBt3BS5Q==/5691072185440427.jpg", "artist": "刘德华,舒淇" }], "msg": "ok" } }, "text": "为您播放【刘德华】的【忘情水】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "为您播放【刘德华】的【忘情水】" } }, { "type": "dialog", "property": { "text": "为您播放【刘德华】的【忘情水】", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "d6aac616-3f27-4eb1-aac8-7c6a74da976b" }], "meta_process_milliseconds": 670 } } ``` **请求示例** (失败,虾米资源,返回推荐20首歌的播放列表,同时结果中以字段code 404表示未搜索到符合条件的歌曲) * <http://api.ruyi.ai/ruyi-api/v1/message?app\_key=APP\_KEY&user\_id=user0&q=我要听梁静茹的稻香> 返回结果 ``` { "code": 0, "msg": "ok", "result": { "_text": "我要听梁静茹的稻香", "msg_id": "dfe6f540-2cb7-486b-91b6-416cd7d35b6f", "intents": [{ "parameters": { "musicGroupId1": "fde16ff3-7188-3484-a3bd-bc03f73625ce", "musicRecordingId": "8f83e6fd-6737-3199-87ac-a1794c8175a7", "artistName1": "梁静茹", "songName": "稻香", "service": "music" }, "action": "歌手+歌曲", "name": "1-按歌手歌名组合点歌", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "music_list": [{ "name": "找个人", "xiami": "3500263", "image": "http://img.xiami.net/images/album/img36/1836/3155111465810499_1.jpg", "artist": "梁静茹" }, { "name": "我都知道", "xiami": "124119", "image": "http://img.xiami.net/images/album/img36/1836/100641383821953_1.jpg", "artist": "梁静茹" }, { "name": "心电感应", "xiami": "1771128951", "image": "http://img.xiami.net/images/album/img36/1836/42791464958086_1.jpg", "artist": "梁静茹" }, { "name": "宁夏", "xiami": "398337", "image": "http://img.xiami.net/images/album/img69/7169/333221472446288_1.jpg", "artist": "梁静茹" }, { "name": "美丽人生", "xiami": "380296", "image": "http://img.xiami.net/images/album/img36/1836/100711363000518_1.jpg", "artist": "梁静茹" }, { "name": "Whoever Finds This I Love You", "xiami": "380209", "image": "http://img.xiami.net/images/album/img36/1836/100721363000472_1.jpg", "artist": "梁静茹" }, { "name": "K歌情人", "xiami": "387805", "image": "http://img.xiami.net/images/album/img89/389/325801395640471_1.jpg", "artist": "梁静茹" }, { "name": "我是真的付出我的爱", "xiami": "124118", "image": "http://img.xiami.net/images/album/img36/1836/100641383821953_1.jpg", "artist": "梁静茹,周华健" }, { "name": "中间", "xiami": "1773801843", "image": "http://img.xiami.net/images/album/img58/7158/18188787821418878782_1.jpg", "artist": "梁静茹" }, { "name": "下一秒钟", "xiami": "124100", "image": "http://img.xiami.net/images/album/img36/1836/100631383823147_1.jpg", "artist": "梁静茹" }, { "name": "你还在不在", "xiami": "380298", "image": "http://img.xiami.net/images/album/img36/1836/100711363000518_1.jpg", "artist": "梁静茹" }, { "name": "半个月亮", "xiami": "380254", "image": "http://img.xiami.net/images/album/img36/1836/100751465709891_1.jpg", "artist": "梁静茹" }, { "name": "幸福的预感", "xiami": "380216", "image": "http://img.xiami.net/images/album/img36/1836/100721363000472_1.jpg", "artist": "梁静茹" }, { "name": "直觉", "xiami": "1234163", "image": "http://img.xiami.net/images/album/img36/1836/610231437026273_1.jpg", "artist": "梁静茹" }, { "name": "只能抱著你", "xiami": "395307", "image": "http://img.xiami.net/images/album/img31/63/58abd3c64b412_3193731_1487655878_1.jpg", "artist": "光良,梁静茹" }, { "name": "我是爱你的", "xiami": "124268", "image": "http://img.xiami.net/images/album/img36/1836/100741383822439_1.jpg", "artist": "梁静茹" }, { "name": "南海姑娘", "xiami": "124115", "image": "http://img.xiami.net/images/album/img36/1836/100641383821953_1.jpg", "artist": "梁静茹" }, { "name": "儿歌", "xiami": "3500265", "image": "http://img.xiami.net/images/album/img36/1836/3155111465810499_1.jpg", "artist": "梁静茹" }, { "name": "我喜欢", "xiami": "380217", "image": "http://img.xiami.net/images/album/img36/1836/100721363000472_1.jpg", "artist": "梁静茹" }, { "name": "我不害怕", "xiami": "380297", "image": "http://img.xiami.net/images/album/img36/1836/100711363000518_1.jpg", "artist": "梁静茹" }], "msg": "未搜索到相应歌曲", "code": 404 } }, "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】" } }, { "type": "dialog", "property": { "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】", "emotion": "happy" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "d6aac616-3f27-4eb1-aac8-7c6a74da976b" }], "meta_process_milliseconds": 184 } } ``` (失败,网易资源,返回推荐20首歌的播放列表,同时结果中以字段code 404表示未搜索到符合条件的歌曲) 返回结果: ``` { "code": 0, "msg": "ok", "result": { "_text": "我要听梁静茹的稻香", "msg_id": "52b4a6b7-4da9-4a1d-9b7b-8bb36a527ac2", "intents": [{ "parameters": { "musicGroupId1": "fde16ff3-7188-3484-a3bd-bc03f73625ce", "musicRecordingId": "8f83e6fd-6737-3199-87ac-a1794c8175a7", "artistName1": "梁静茹", "songName": "稻香", "service": "music" }, "action": "歌手+歌曲", "name": "1-按歌手歌名组合点歌", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "music_list": [{ "name": "找个人", "music163": "254107", "image": "http://p3.music.126.net/qy5RFE6nJ45yfnJECPlooA==/36283883717788.jpg", "artist": "梁静茹" }, { "name": "我都知道", "music163": "254082", "image": "http://p3.music.126.net/Xj5cE1PQz6fe5r78yQWPsg==/67070209307376.jpg", "artist": "梁静茹" }, { "name": "心电感应", "music163": "254053", "image": "http://p4.music.126.net/vMnrAM2EONePwWhFhCoGsg==/131941395334085.jpg", "artist": "梁静茹" }, { "name": "宁夏", "music163": "254083", "image": "http://p4.music.126.net/Xj5cE1PQz6fe5r78yQWPsg==/67070209307376.jpg", "artist": "梁静茹" }, { "name": "美丽人生", "music163": "254345", "image": "http://p4.music.126.net/6SwAIJ_wbwhlreZnaRbHEg==/5834008696996307.jpg", "artist": "梁静茹" }, { "name": "Whoever Finds This I Love You", "music163": "254380", "image": "http://p4.music.126.net/D_1YWUoLkD2OXey1DdJfrA==/30786325589795.jpg", "artist": "梁静茹" }, { "name": "我是真的付出我的爱", "music163": "254234", "image": "http://p3.music.126.net/kgWbj5zK_kYEhCmjXrgY_g==/107752139534143.jpg", "artist": "梁静茹,周华健" }, { "name": "情歌金曲", "music163": "28103380", "image": "http://p3.music.126.net/-a0TZOuOXBrZnfWKfDu3Yg==/3406287024083302.jpg", "artist": "梁静茹" }, { "name": "败犬标签", "music163": "4872622", "image": "http://p3.music.126.net/qgLpl8TU17ENjI9cd1wb_A==/48378511639148.jpg", "artist": "梁静茹" }, { "name": "中间", "music163": "254279", "image": "http://p3.music.126.net/dr9lwZeuTDjbVTDaz5K0zQ==/18796151278553471.jpg", "artist": "梁静茹" }, { "name": "下一秒钟", "music163": "254193", "image": "http://p3.music.126.net/FiofHIdZrsUqdA6rrXsYWg==/18906102439652722.jpg", "artist": "梁静茹" }, { "name": "你还在不在", "music163": "254350", "image": "http://p3.music.126.net/6SwAIJ_wbwhlreZnaRbHEg==/5834008696996307.jpg", "artist": "梁静茹" }, { "name": "宁夏 + 勇气 + 在爱里等你 - live", "music163": "29932280", "image": "http://p3.music.126.net/S14YyURO1IOOnSjJkV0A4A==/2881819976558355.jpg", "artist": "梁静茹" }, { "name": "半个月亮", "music163": "254487", "image": "http://p4.music.126.net/jvTQsP85pqCUUeuLuQT7TA==/39582418606104.jpg", "artist": "梁静茹" }, { "name": "幸福的预感", "music163": "254402", "image": "http://p3.music.126.net/D_1YWUoLkD2OXey1DdJfrA==/30786325589795.jpg", "artist": "梁静茹" }, { "name": "直觉", "music163": "254096", "image": "http://p3.music.126.net/19CSY865LBTVV6ZOEOBAUA==/122045790688915.jpg", "artist": "梁静茹" }, { "name": "我是爱你的", "music163": "254464", "image": "http://p3.music.126.net/BIjmMDmL0Lc_VpPisVdyww==/81363860468148.jpg", "artist": "梁静茹" }, { "name": "南海姑娘", "music163": "254228", "image": "http://p4.music.126.net/kgWbj5zK_kYEhCmjXrgY_g==/107752139534143.jpg", "artist": "梁静茹" }, { "name": "花钱找男人!!??", "music163": "4872619", "image": "http://p3.music.126.net/qgLpl8TU17ENjI9cd1wb_A==/48378511639148.jpg", "artist": "梁静茹" }, { "name": "儿歌", "music163": "254109", "image": "http://p3.music.126.net/qy5RFE6nJ45yfnJECPlooA==/36283883717788.jpg", "artist": "梁静茹" }], "msg": "未搜索到相应歌曲", "code": 404 } }, "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】" } }, { "type": "dialog", "property": { "text": "未搜索到相应歌曲,为您推荐【梁静茹】的【找个人】", "emotion": "happy" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "d6aac616-3f27-4eb1-aac8-7c6a74da976b" }], "meta_process_milliseconds": 558 } } ``` **详细参数说明** | 名称 | 类型 | 说明 | | :--- | :--- | :--- | | service | String | 服务名称 | | artistname | String | 歌手名,多个歌手用后缀1,2...数字区分 | | musicRecordingId | String | 歌曲在音乐知识图谱中的id | | musicGroupId | String | 歌手在音乐知识图谱中的id,多个歌手用后缀1,2...数字区分 | | tag | String | 标签名,包含区分、流派、场景、心情等,多个标签用后缀1,2...数字区分 | | keyword | String | 映射标签名的关键词,主要关于场景和心情 | | songName | String | 识别的歌曲名 | | music_list | Array | 返回的歌曲列表 | | xiami | String | 虾米网站歌曲ID | | music163 | String | 网易云音乐网站歌曲ID | | image | String | 歌曲封面地址 | | name | String | 歌曲名称 |