Chord Analyzer Skill
Analyze music audio files to extract chord progressions, key signature, tempo, and song structure.
When to Use
✅ USE this skill when:
- - User wants to analyze a song's chords and harmony
- "What are the chords in this song?"
- "Analyze this audio file"
- "Extract the chord progression"
- "What key is this song in?"
- User provides an audio file path and asks for musical analysis
When NOT to Use
❌ DON'T use this skill when:
- - Only wants general music info (lyrics, artist) → use web search
- Wants to generate music → use music generation skills
- Needs professional-grade transcription → recommend specialized software (Chordify, Hookpad)
- Requires detailed instrument separation → use dedicated source separation tools
Supported Formats
- - Audio: mp3, wav, m4a, flac, ogg
- Duration: Works best for songs under 5 minutes
Installation
First time use requires installing dependencies:
CODEBLOCK0
Usage
Basic Analysis
CODEBLOCK1
Script Integration
Copy the chord_analyzer.py script to your workspace and modify the audio_path variable:
CODEBLOCK2
Output
The analyzer provides:
- 1. Key Signature: Detected musical key (e.g., C, F#m, G)
- Tempo: Speed in BPM with rhythm classification
- Chord Progression: Complete chord sequence with timestamps
- Chord Statistics: Most frequently used chords
- Song Structure: Intro/Verse/Outro segmentation (basic)
Sample Output
CODEBLOCK3
How It Works
- 1. Load Audio: Uses
librosa.load() to read audio at 22.05kHz - Extract Chroma: Computes chroma features (pitch class profiles) using STFT
- Detect Key: Analyzes chroma energy across all 12 keys (major + minor)
- Track Tempo: Uses
librosa.beat.beat_track() for tempo detection - Analyze Chords: Samples chroma at measure boundaries and matches against chord templates
- Merge & Simplify: Combines consecutive identical chords
Limitations
- - Accuracy: Chord detection is approximated; not professional-grade
- Complexity: Struggles with heavily layered or distorted music
- Structure: Simple segmentation (not verse/chorus detection)
- Melody: Does not extract melodic lines or instrument parts
- Chord Extensions: Detects basic triads (major, minor, diminished), not 7th/9th chords
For Complete Transcription
For professional music transcription, recommend:
- - Chordify: https://chordify.net (online chord detection)
- Hookpad: https://www.hooktheory.com/hookpad (theory + chords)
- MuseScore: https://musescore.org (manual transcription)
- Capo: https://capoapp.com (slow down + chord detection)
Notes
- - Analysis takes ~10-30 seconds depending on song length
- Best results with clear, non-distorted audio
- Works best for pop/rock/folk styles with clear harmony
- Not suitable for atonal, experimental, or heavily percussive music
和弦分析技能
分析音乐音频文件,提取和弦进行、调性、速度和歌曲结构。
使用时机
✅ 使用此技能的场景:
- - 用户想要分析歌曲的和弦与和声
- 这首歌的和弦是什么?
- 分析这个音频文件
- 提取和弦进行
- 这首歌是什么调?
- 用户提供音频文件路径并要求进行音乐分析
不使用时机
❌ 不要使用此技能的场景:
- - 仅需要一般音乐信息(歌词、歌手)→ 使用网络搜索
- 想要生成音乐 → 使用音乐生成技能
- 需要专业级转写 → 推荐专业软件(Chordify、Hookpad)
- 需要详细的乐器分离 → 使用专门的音源分离工具
支持格式
- - 音频:mp3、wav、m4a、flac、ogg
- 时长:5分钟以内的歌曲效果最佳
安装
首次使用需要安装依赖:
bash
pip3 install librosa numpy scipy scikit-learn soundfile
使用方法
基础分析
bash
分析音频文件
python3 chord_analyzer.py
编辑脚本以更改音频路径
默认:/Users/chentiewen/Music/网易云音乐/example.mp3
脚本集成
将 chordanalyzer.py 脚本复制到工作区,并修改 audiopath 变量:
python
audio_path = /path/to/your/song.mp3
result = analyzeaudio(audiopath)
输出内容
分析器提供以下信息:
- 1. 调性:检测到的音乐调式(例如:C、F#m、G)
- 速度:以BPM为单位的速度及节奏分类
- 和弦进行:包含时间戳的完整和弦序列
- 和弦统计:最常用的和弦
- 歌曲结构:前奏/主歌/尾奏分段(基础版)
示例输出
调性: F#m
速度: 123.0 BPM
节奏: 快板 (Allegro)
和弦走向:
F#mdim → A → D → Bm → E → A → D → Bm → E ...
主要和弦:
A: 15次 (20.3%)
E: 14次 (18.9%)
D: 12次 (16.2%)
工作原理
- 1. 加载音频:使用 librosa.load() 以22.05kHz采样率读取音频
- 提取色度:通过STFT计算色度特征(音高类别轮廓)
- 检测调性:分析所有12个调(大调+小调)的色度能量
- 追踪速度:使用 librosa.beat.beat_track() 进行速度检测
- 分析和弦:在小节边界采样色度,并与和弦模板匹配
- 合并简化:合并连续相同的和弦
局限性
- - 准确性:和弦检测为近似值,非专业级别
- 复杂性:对层次丰富或失真严重的音乐处理效果不佳
- 结构:简单分段(非主歌/副歌检测)
- 旋律:不提取旋律线或乐器部分
- 和弦扩展:仅检测基本三和弦(大调、小调、减三和弦),不检测七和弦/九和弦
完整转写建议
如需专业音乐转写,推荐使用:
- - Chordify:https://chordify.net(在线和弦检测)
- Hookpad:https://www.hooktheory.com/hookpad(理论+和弦)
- MuseScore:https://musescore.org(手动转写)
- Capo:https://capoapp.com(慢放+和弦检测)
注意事项
- - 分析时间约10-30秒,取决于歌曲长度
- 清晰、无失真的音频效果最佳
- 最适合和声清晰的流行/摇滚/民谣风格
- 不适用于无调性、实验性或打击乐为主的音乐