返回顶部
m

music-identify音乐识别

Identify songs from audio clips using AudD API and optionally queue them to Spotify. Triggers on /songsearch command, voice messages with song identification intent, or when user asks "what song is this." Also handles recall queries like "what did I shazam" or "what was that song" by reading the music log. Works with any audio file (OGG, MP3, WAV, etc.).

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.2.0
安全检测
已通过
139
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

music-identify

音乐识别

通过AudD识别音频中的歌曲,返回包含Spotify链接的歌曲信息,并可选择将歌曲加入用户当前活跃的Spotify会话队列。

运行时依赖

需要在$PATH中安装:

  • - curl — 向AudD和Spotify API发送HTTP请求
  • jq — 解析所有API响应的JSON数据
  • python3 — 仅用于Spotify OAuth认证流程(scripts/spotify-auth.py)

凭证信息

凭证位置是否必需用途
AudD API密钥~/.config/audd/api_key歌曲识别
Spotify OAuth令牌
~/.config/spotify/tokens.json | 否(可选) | 加入Spotify队列 | | Spotify应用凭证 | ~/.config/spotify/credentials.json | 否(可选) | 令牌刷新 |

安全说明:

  • - 所有凭证文件应设置权限:chmod 600。
  • 本技能不会读取、存储或访问任何平台令牌(Telegram、Discord等)。来自消息平台的音频文件下载由宿主代理处理,而非本技能。

触发方式

  • - 用户发送/songsearch后跟语音消息或音频文件
  • 用户要求识别音频中的歌曲(这是什么歌、识别这首歌、类似Shazam)
  • 用户要求回忆之前识别过的歌曲(那首歌是什么、我之前Shazam过什么)

设置

AudD API密钥(必需)

  1. 1. 在注册(免费套餐:300次请求,无需信用卡)
  2. 保存密钥:
bash mkdir -p ~/.config/audd echo YOURKEY > ~/.config/audd/apikey chmod 600 ~/.config/audd/api_key

Spotify集成(可选)

  1. 1. 在创建Spotify开发者应用
  2. 将重定向URI设置为你的回调URL
  3. 保存凭证:
bash mkdir -p ~/.config/spotify cat > ~/.config/spotify/credentials.json << EOF {clientid: ..., clientsecret: ..., redirect_uri: https://your-host/callback} EOF chmod 600 ~/.config/spotify/credentials.json
  1. 4. 运行认证流程:python3 scripts/spotify-auth.py
  2. 在浏览器中打开打印的URL,授权后令牌将自动保存
  3. chmod 600 ~/.config/spotify/tokens.json

工作流程 — 歌曲识别

当触发歌曲识别时:

  1. 1. 如果用户尚未提供语音片段,提示用户提供。
  2. 将音频文件保存到临时位置(例如/tmp/music-identify-.ogg)。宿主代理负责从消息平台(Telegram、Discord等)下载音频——本技能仅需要本地文件路径。
  3. 运行识别:
bash scripts/identify.sh /path/to/audio-file.ogg
  1. 4. 解析JSON结果并回复。
  2. 如果已配置Spotify且处于活跃状态,将曲目加入队列。
  3. 将识别记录写入memory/music-log.json。

支持的格式: OGG/Opus、MP3、WAV、FLAC、M4A。无需转码——AudD接受所有常见音频格式。

工作流程 — Spotify队列

成功识别后,如果~/.config/spotify/tokens.json中存在Spotify令牌:

bash

检查是否有内容正在播放


scripts/spotify-queue.sh status

将识别到的曲目加入队列

scripts/spotify-queue.sh queue spotify:track:

如果未找到活跃的Spotify会话,则仅返回Spotify链接。

令牌刷新由spotify-queue.sh在收到401响应时自动处理。

响应格式

  • - 找到匹配:🎵 {歌曲名} by {艺术家} + 下一行的Spotify链接。如果Spotify活跃,注明已加入队列。
  • 找到匹配,无Spotify匹配:🎵 {歌曲名} by {艺术家}(无链接)
  • 未找到:无法识别该音频。请尝试录制更长的片段,包含更多旋律(5秒以上效果最佳)。
  • 错误:识别过程中出现问题,请重试。
  • 缺少AudD密钥:未配置AudD API密钥。请前往https://audd.io获取密钥并保存至~/.config/audd/api_key

记忆记录

将识别到的歌曲追加到memory/music-log.json(每行一个JSON对象):
json
{date:2026-03-22,time:14:30,title:Viva La Vida,artist:Coldplay,album:Viva la Vida,spotify:https://open.spotify.com/track/...}

如果文件不存在则创建。对于回忆查询,读取并展示此日志。

脚本

脚本用途依赖
scripts/identify.sh <audio_file>将音频POST到AudD,返回JSONcurl, jq
scripts/spotify-auth.py [--url]
一次性Spotify OAuth认证流程 | python3 | | scripts/spotify-queue.sh queue | 将曲目加入活跃Spotify队列 | curl, jq | | scripts/spotify-queue.sh status | 检查当前Spotify播放状态 | curl, jq |

identify.sh的退出码:0=找到,1=未找到,2=错误。

API参考

有关AudD端点详情、参数和响应格式,请参阅references/audd-api.md。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 music-identify-1776086161 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 music-identify-1776086161 技能

通过命令行安装

skillhub install music-identify-1776086161

下载

⬇ 下载 music-identify v1.2.0(免费)

文件大小: 7.16 KB | 发布时间: 2026-4-14 10:22

v1.2.0 最新 2026-4-14 10:22
v1.2.0: Security fix — removed all Telegram bot token references and config path grep instructions from SKILL.md. Audio download from messaging platforms is now explicitly delegated to the host agent. Skill only handles local audio files. Removed undocumented config path access. Should resolve VirusTotal and OpenClaw security scan flags.

Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com

p2p_official_large
返回顶部