🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 3.2.14 我爱猜歌名 #### (1)功能说明 一款欲罢不能的猜歌名游戏,歌曲种类丰富,玩法上手简单,支持无限重听和跳过。 #### (2)接口说明 **请求方法** * POST **请求地址** * 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)请求示例 **请求范例** 打开我爱猜歌名 天蝎蝴蝶 再听一遍 特别的人 跳过 退出 **请求示例唤醒** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=打开我爱猜歌名 (唤醒) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "打开我爱猜歌名", "msg_id": "dc5806dd-8421-46a5-b92d-6df7f5f560bd", "intents": [ { "parameters": { "想玩": "打开我爱猜歌名", "cueWords": "“再听一遍”##“跳过”##“我不知道”", "service": "woaicaigeming" }, "action": "猜歌名-开始", "name": "猜歌名-开始", "result": { "name": "天蝎蝴蝶", "artist": "阿杜", "a_url": "https://ruyi-static.ruyi.ai/a402.mp3", "id": "402", "b_url": "https://ruyi-static.ruyi.ai/b402.mp3", "lastSongName": "天蝎蝴蝶", "lastSingerName": "阿杜", "visitTimes": 128 "text": "欢迎来玩我爱猜歌名,游戏很简单,请听完每首音乐后回答出歌曲名字,我们现在开始吧。", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "欢迎来到我爱猜歌名。请认真听完歌曲后回答歌名,现在我们开始吧!" } }, { "type": "wechat.music", "property": { "name": null, "description": null, "music_url": "https://ruyi-static.ruyi.ai/b402.mp3", "title": null } },{ "type": "voice", "property": { "name": null, "voice_url": "https://image.ruyi.ai/%E5%9C%A3%E8%AF%9E%E5%94%A4%E9%86%92.mp3" } }, { "type": "dialog", "property": { "text": "欢迎来玩我爱猜歌名,游戏很简单,请听完每首音乐后回答出歌曲名字,我们现在开始吧。", "emotion": "like" } }, { "type": "voice", "property": { "name": null, "voice_url": "https://ruyi-static.ruyi.ai/b402.mp3" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "6fbe3220-b2ae-4834-bb6c-1af304c01f86", "id": "9c70755f-e167-4571-8510-e0be3a1dc005" } ], "meta_process_milliseconds": 391 } ``` **请求示例错误** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=特别的人 (回答错误) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "特别的人", "msg_id": "50af95da-2bfa-4090-b431-f21c9b327b92", "intents": [ { "parameters": { "text": "特别的人", "fromAnswer": "true", "cueWords": "“重听”##“跳过”", "cueWords1": "“跳过”##“答案是啥”##“这是什么歌”", "cueWords2": "“重听”##“跳过”", "cueWords3": "“不玩了”##“重新开始”", "service": "woaicaigeming" }, "action": "猜歌名-回答", "name": "猜歌名-回答", "result": { "name": "答案", "artist": "杨坤、郭采洁", "a_url": null, "id": "614", "b_url": "https://ruyi-static.ruyi.ai/b614.mp3", "isRight": "no", "lastSongId": "467", "lastSongName": "十七岁的雨季", "lastSingerName": "林志颖" "text": "答案是林志颖的《十七岁的雨季》。请听下一首", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "答案是林志颖的《十七岁的雨季》。请听下一首" } }, { "type": "wechat.voice", "property": { "name": null, "media_id": "https://ruyi-static.ruyi.ai/b614.mp3", "title": null } }, { "type": "wechat.text", "property": { "text": "答案是林志颖的《十七岁的雨季》。请听下一首" } }, { "type": "voice", "property": { "name": null, "voice_url": "http://image.ruyi.ai/%E7%AC%AC%E4%BA%8C%E6%AC%A1%E5%9B%9E%E7%AD%94%E9%94%99%E8%AF%AF.wav" } }, { "type": "dialog", "property": { "text": "这首歌是林志颖的《十七岁的雨季》。请认真听下一首吧。加油哦。", "emotion": "calm" } }, { "type": "voice", "property": { "name": null, "voice_url": "https://ruyi-static.ruyi.ai/b614.mp3" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "6fbe3220-b2ae-4834-bb6c-1af304c01f86", "id": "fede0a44-b597-4242-b751-a61f593f214a" } ], "meta_process_milliseconds": 192 } ``` **请求示例退出** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=退出 (退出游戏) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "退出", "msg_id": "6083d3fa-93e7-49a4-b36f-ee100eea1306", "intents": [ { "parameters": { "cueWords": "“打开我爱猜歌名”", "service": "woaicaigeming" }, "action": "退出", "name": "退出如意技能", "result": { "rightAnswerCount": 1, "score": 1, "rank": 0, "top10": [ { "userId": "ruyi-test-6fbe3220-b2ae-4834-bb6c-1af304c01f86", "score": 1, "rankInTop10": 1 } ], "rankDaily": "1", "scoreBestDaily": 1 "text": "你在我爱猜歌名中答对了1题,你今日的最佳排名是:第1名,棒棒的!", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "你在我爱猜歌名中答对了1题,你今日的最佳排名是:第1名,棒棒的!" } }, { "type": "wechat.text", "property": { "text": "你在我爱猜歌名中答对了1题,击败了全国5%的用户" } }, { "type": "custom", "property": { "name": null, "content": null } }, { "type": "voice", "property": { "name": null, "voice_url": "https://image.ruyi.ai/%E6%9C%89%E6%88%90%E7%BB%A9%E9%80%80%E5%87%BA.mp3" } }, { "type": "dialog", "property": { "text": "你在我爱猜歌名中答对了1题,你今日的最佳排名是:第1名,棒棒的!", "emotion": "like" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "6fbe3220-b2ae-4834-bb6c-1af304c01f86", "id": "153d7a42-c388-45fa-95a2-aa96a8885665" } ], "meta_process_milliseconds": 239 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |name|String|歌名 |id | int | 当前歌曲id |artist|String|歌手 |b_url | int |歌曲音频链接 |isRight| String |用户回答是否正确 |text|String|机器返回内容 |degree | String |相关指标参数 |rightAnswerCount | int |答对题目数量 |lastSongId|int|上一首歌歌曲id |lastSingerName | String |上一首歌手名 |lastSongName| String |上一首歌名 |rankDaily | int |答题得分排名 **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 打开我爱猜歌名 |重听 | 重听 |跳过 | 跳过 |退出 | 退出