多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 3.5.6 Smart Audio #### (1)功能说明 模糊场景下抽取聊天关键词,智能推荐儿童听听中相关的有声资源。数据主要来自工程师爸爸、喜马拉雅FM和蜻蜓FM,返回url包含mp3和m4a两种格式。 #### (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) 请求示例 **请求范例** _宝宝要听儿歌_ **请求示例** (成功,返回符合结果的单曲,和该单曲所在专辑最多10个曲目的播放列表) * http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=宝宝要听儿歌 返回结果 ``` { "code": 0, "msg": "ok", "result": { "_text": "宝宝要听儿歌", "msg_id": "5a6f63d9-5945-41fe-9041-9f5e3e98c160", "intents": [{ "parameters": { "statedIn": "", "tag": "儿歌", "service": "smart_audio" }, "action": "smart-audio", "name": "smart audio", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "track_list": [{ "name": "嘟拉儿歌 024打电话", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "嘟拉儿歌", "identifier": "4021184", "image": "http://fdfs.xmcdn.com/group11/M00/35/FE/wKgDa1cN68HwdMK_AARP3SWiU0Q661_mobile_meduim.png", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "22167041", "position": 2, "durationInSeconds": 196, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group19/M01/34/13/wKgJJlfofFbjXj-sABfyX9-X3ng503.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group19/M01/33/D9/wKgJK1fofFiAw7BRABhA1fKMiCY986.m4a", "encodingFormat": "m4a" }] }] }, { "name": "英语儿歌-This Is The Way", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "精选英语儿歌", "identifier": "4383321", "image": "http://fdfs.xmcdn.com/group14/M01/7B/10/wKgDZFdF0rrwbrYdAAF88Pre0-Y561_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "16226785", "position": 8, "durationInSeconds": 61, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group14/M05/7B/1E/wKgDY1dF1H7j0W3JAAd0OedfpOo299.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group14/M05/7B/1E/wKgDY1dF1HyCsCEUAAePO3oZj-s716.m4a", "encodingFormat": "m4a" }] }] }, { "name": "你好,花木兰", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "兔小贝儿歌-2", "identifier": "246643", "image": "http://fdfs.xmcdn.com/group5/M01/5D/18/wKgDtVOs1AORmriMAAFwDkni1vo926_mobile_meduim.png", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "23942470", "position": 160, "durationInSeconds": 249, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group25/M06/00/09/wKgJNlgQDlnzPZ9zAB6CXyVOcsc534.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group25/M06/00/0C/wKgJMVgQDlnTNMFPAB7j0QbIF3M384.m4a", "encodingFormat": "m4a" }] }] }, { "name": "【米粒妈分享】A-Hunting We Will Go", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "【最全】迪士尼最佳英文儿歌合集,宝贝磨耳朵必备!", "identifier": "3934688", "image": "http://fdfs.xmcdn.com/group28/M09/7E/3D/wKgJXFkpAQ6x0ytGAAEWn_yKL9Q801_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "16423524", "position": 31, "durationInSeconds": 74, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group13/M02/80/A7/wKgDXldLvRmA6vNTAAkggKfpwX8291.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group13/M02/80/BA/wKgDXVdLvRqxAKAwAAlCWmwaX_k513.m4a", "encodingFormat": "m4a" }] }] }, { "name": "Track 11", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "字母舞蹈", "identifier": "3337772", "image": "http://fdfs.xmcdn.com/group13/M06/C9/24/wKgDXVZq5MeTEYEhAAd-3wcoPkk402_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "10711341", "position": 125, "durationInSeconds": 46, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group8/M05/C8/E5/wKgDYVZq58CgFO1hAAWrvAtUjSI112.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group9/M09/C9/0A/wKgDYlZq6CGA4LPMAAXCcwnzoVg964.m4a", "encodingFormat": "m4a" }] }] }, { "name": "Christopher columbus小菲清唱", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "My very first mother goose鹅妈妈经典童谣", "identifier": "292196", "image": "http://fdfs.xmcdn.com/group4/M05/8F/25/wKgDtFROOPnB91Q4AAKR5JSs4V4538_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "4601517", "position": 17, "durationInSeconds": 22, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group5/M05/D5/69/wKgDtVSIcUigo85WAAK7ZOMQWsE524.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group16/M03/4F/89/wKgDbFWzXZWQetykAALHiOMimWU784.m4a", "encodingFormat": "m4a" }] }] }, { "name": "61 Roses Are Red", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "鹅妈妈童谣", "identifier": "374575", "image": "http://fdfs.xmcdn.com/group6/M02/FC/12/wKgDhFUjex_BYZlpAAIHxs7Ciy0600_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "6140840", "position": 59, "durationInSeconds": 19, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group6/M0A/FC/1C/wKgDhFUjfiGAV6ElAAJUhCpSQ68311.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group16/M0B/3D/4E/wKgDbFWd8jHBZWkKAAJhQhdhMoo401.m4a", "encodingFormat": "m4a" }] }] }, { "name": "192 照相机", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "洪恩宝宝乐500首(1-200)", "identifier": "342560", "image": "http://fdfs.xmcdn.com/group6/M09/27/3A/wKgDhFTcOMeTS1VfAACyKRebLBQ387_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "5463588", "position": 8, "durationInSeconds": 15, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group6/M03/27/F2/wKgDhFTcXgDCPF6xAAHnhcYY3Ag933.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group14/M03/34/58/wKgDY1WTj_Lg1C3CAAHyupceCd8146.m4a", "encodingFormat": "m4a" }] }] }, { "name": "1-Make A Circle", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "DrBing分级儿歌-1", "identifier": "365808", "image": "http://fdfs.xmcdn.com/group6/M02/C1/2B/wKgDhFUSfurydvNlAAB9piO_Oqo498_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "5990015", "position": 20, "durationInSeconds": 64, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group6/M04/C5/2F/wKgDg1USfabx3Uh-AAfoyST7aco674.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group11/M03/29/35/wKgDa1WFRhKwCHhhAAgFSLyhO8Y130.m4a", "encodingFormat": "m4a" }] }] }, { "name": "03 Animal Song", "@type": ["MusicRecording", "CreativeWork", "Thing"], "mergedFrom": [{ "inAlbum": { "name": "Wee Sing- Animals, Animals, Animals 动物大游行", "identifier": "4091469", "image": "http://fdfs.xmcdn.com/group14/M0B/48/9E/wKgDZFcRtd3gRkGhAAFm9FPtak4573_mobile_meduim.jpg", "@type": ["MusicAlbum", "CreativeWork", "Thing"] }, "identifier": "14479942", "position": 1, "durationInSeconds": 38, "statedIn": "www.ximalaya.com", "@type": ["MusicRecording", "CreativeWork", "Thing"], "audio": [{ "contentUrl": "http://fdfs.xmcdn.com/group8/M03/47/26/wKgDYFcRtjzS3GIPAASx5GHNcso456.mp3", "encodingFormat": "mp3" }, { "contentUrl": "http://audio.xmcdn.com/group8/M03/47/25/wKgDYVcRtj3ijp3dAATFnw0RAPQ472.m4a", "encodingFormat": "m4a" }] }] }], "msg": "ok" } }, "text": "即将播放【嘟拉儿歌 024打电话】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "即将播放【嘟拉儿歌 024打电话】" } }, { "type": "dialog", "property": { "text": "即将播放【嘟拉儿歌 024打电话】", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "afc2b4c4-77fc-4117-af0d-9ea6f3f150a6", "id": "b9423786-9aa0-45a2-ba30-f7100b47688c" }], "meta_process_milliseconds": 307 } } ``` **详细参数说明** | 名称 | 类型 | 说明 | | :--- | :--- | :--- | | service | String | 服务名称 | |tag|String | 标签名,包含儿歌、故事、国学、诗词等,多个标签用后缀1,2...数字区分 | |trackName|String |识别到的音频名称| |statedIn|String |数据来源网站| |track_list|String |返回的音频列表| |name|String |音频名称| |@type|String |实体类型| |identifier|String|数据来源网站ID| |durationInSeconds|String|音频时长| |position|String|音频在专辑中的位置| |inAlbum|String|音频所在专辑| |image|String | 专辑封面地址 |