Hum2Song
Turn a hummed melody into a complete song with local audio processing, without uploading sensitive recordings to third-party services.
Overview
This skill converts user humming or singing into complete songs using local AI models. The entire pipeline runs on your machine - no audio data is sent to external services.
Pipeline:
- 1. 🎤 Audio Input → 2. 🎵 MIDI Extraction → 3. 🎼 Music Generation → 4. 🎧 Complete Song
Triggers
Use this skill when the user:
- - Hums or sings a melody and wants to turn it into a full song
- Has an audio recording of humming/singing
- Wants to create music from their own melodic ideas
- Asks to "turn my humming into a song"
Requirements
System Dependencies
CODEBLOCK0
Optional: ACE-Step for Music Generation (User Choice)
ACE-Step is an optional local AI. Users decide whether to install it.
CODEBLOCK1
Note: First use downloads ~4GB model weights to local cache. No automatic downloads.
Core Workflow
Step 1: Extract MIDI from Audio
Use Basic Pitch (Spotify's open source tool) to convert humming to MIDI:
CODEBLOCK2
Step 2: Enhance MIDI Structure
Clean and enhance the extracted MIDI:
CODEBLOCK3
Step 3: Generate Full Song
Option A: ACE-Step (Local AI, Optional)
Only if user has manually installed ACE-Step:
CODEBLOCK4
Option B: MIDI + SoundFont (No AI)
CODEBLOCK5
Usage
Quick Start
CODEBLOCK6
Parameters
| Parameter | Description | Options |
|---|
| INLINECODE0 | Input audio file | Any audio format |
| INLINECODE1 |
Music style | pop, rock, jazz, classical, electronic |
|
--mood | Song mood | upbeat, calm, energetic, melancholic |
|
--duration | Target duration (seconds) | 30-300 |
|
--output | Output file path | .mp3, .wav, .mid |
Response Format
When User Provides Audio
CODEBLOCK7
When Complete
CODEBLOCK8
Example Interactions
Example 1: User Hums Audio
CODEBLOCK9
Example 2: User Specifies Style
CODEBLOCK10
Example 3: User Wants MIDI Output
User: Can I get the MIDI file to edit myself?
AI: 🎼 Absolutely!
I'll generate:
• Extracted MIDI (raw melody)
• Enhanced MIDI (quantized, cleaned)
• Full arrangement MIDI (all instruments)
All files will be in: ~/Music/hum2song_export/
Technical Details
Audio Processing
Input Formats: WAV, MP3, M4A, FLAC, OGG
Sample Rate: Automatically converted to 44.1kHz
Channels: Mono/Stereo → Mono for processing
MIDI Extraction
Model: Basic Pitch (Spotify, ICASSP 2022)
Pitch Range: C1 to C8
Note Detection: Polyphonic capable
Timing Resolution: 10ms
Music Generation
ACE-Step Model:
- - Size: 1B parameters (base), 3B (large)
- Training: Licensed music dataset
- Output: 44.1kHz stereo
- Latency: ~1s per second of audio on M1 Mac
SoundFont Synthesis:
- - No AI required
- Real-time synthesis
- High-quality instrument sounds
- Deterministic output
Limitations
- - Requires local Python environment setup
- ACE-Step needs ~4GB RAM for base model
- Processing time: 2-5 minutes for a 2-minute song
- Quality depends on humming clarity
- Complex harmonies may not be fully captured
Privacy & Security
✅ All processing is local - Your audio never leaves your machine
✅ No cloud services - No API keys or external uploads
✅ Open source tools - Basic Pitch, ACE-Step, Pretty MIDI
✅ No data collection - Nothing is logged or transmitted
References
- -
basic-pitch.md - Audio to MIDI extraction - INLINECODE6 - AI music generation
- INLINECODE7 - MIDI processing
- INLINECODE8 - Audio analysis utilities
Technical Information
| Attribute | Value |
|---|
| Name | Hum2Song |
| Slug |
hum2song |
|
Version | 3.0.4 |
|
Category | Audio / Music Generation |
|
Tags | music, audio, midi, ai-generation, local-processing |
|
License | MIT-0 |
Note: This skill requires local setup of Python dependencies. All audio processing happens on your device for maximum privacy.
Hum2Song
通过本地音频处理将哼唱的旋律转化为完整的歌曲,无需将敏感录音上传至第三方服务。
概述
本技能使用本地AI模型将用户的哼唱或演唱转化为完整歌曲。整个处理流程在您的机器上运行——没有任何音频数据发送到外部服务。
处理流程:
- 1. 🎤 音频输入 → 2. 🎵 MIDI提取 → 3. 🎼 音乐生成 → 4. 🎧 完整歌曲
触发条件
当用户出现以下情况时使用本技能:
- - 哼唱或演唱一段旋律并希望将其转化为完整歌曲
- 拥有哼唱/演唱的音频录音
- 希望根据自己的旋律创意创作音乐
- 要求把我的哼唱变成一首歌
环境要求
系统依赖
bash
macOS
brew install ffmpeg fluidsynth
Ubuntu/Debian
sudo apt-get install ffmpeg fluidsynth
Python包
pip install basic-pitch pretty_midi librosa soundfile numpy
可选:ACE-Step音乐生成(用户自行选择)
ACE-Step是一个可选的本地AI。由用户决定是否安装。
bash
用户如需AI生成功能则手动安装
否则,默认SoundFont合成无需AI即可工作
git clone https://github.com/ace-step/ace-step.git
pip install -r ace-step/requirements.txt
注意: 首次使用会下载约4GB模型权重到本地缓存。不会自动下载。
核心工作流程
步骤1:从音频提取MIDI
使用Basic Pitch(Spotify的开源工具)将哼唱转换为MIDI:
python
from basic_pitch.inference import predict
from basicpitch import ICASSP2022MODELPATH
将音频转换为MIDI
model
output, mididata, note_events = predict(humming.wav)
midi_data.write(extracted.mid)
步骤2:优化MIDI结构
清理并优化提取的MIDI:
python
import pretty_midi
加载提取的MIDI
pm = pretty_midi.PrettyMIDI(extracted.mid)
量化音符以修正时值
for instrument in pm.instruments:
for note in instrument.notes:
note.start = round(note.start * 4) / 4 # 量化为十六分音符
note.end = round(note.end * 4) / 4
保存优化后的MIDI
pm.write(enhanced.mid)
步骤3:生成完整歌曲
选项A:ACE-Step(本地AI,可选)
仅当用户已手动安装ACE-Step时使用:
python
from ace_step import MusicGenerator
加载模型(本地运行,首次使用下载权重)
generator = MusicGenerator.from_pretrained(ace-step/base)
从MIDI生成音乐
audio = generator.generate
frommidi(
midi_path=enhanced.mid,
style=pop,
mood=upbeat,
duration=120
)
保存结果
audio.save(complete_song.mp3)
选项B:MIDI + SoundFont(无需AI)
python
import pretty_midi
加载MIDI
pm = pretty_midi.PrettyMIDI(enhanced.mid)
使用高质量SoundFont合成
audio
data = pm.fluidsynth(fs=44100, sf2path=path/to/good_soundfont.sf2)
保存为WAV
import soundfile as sf
sf.write(complete
song.wav, audiodata, 44100)
使用方法
快速开始
bash
运行完整流程
python ~/.openclaw/skills/hum2song/scripts/hum2song.py \
--input my_humming.wav \
--style pop \
--mood upbeat \
--output my_song.mp3
参数说明
| 参数 | 描述 | 选项 |
|---|
| --input | 输入音频文件 | 任意音频格式 |
| --style |
音乐风格 | pop, rock, jazz, classical, electronic |
| --mood | 歌曲情绪 | upbeat, calm, energetic, melancholic |
| --duration | 目标时长(秒) | 30-300 |
| --output | 输出文件路径 | .mp3, .wav, .mid |
响应格式
用户提供音频时
🎵 我将把您的哼唱转化为完整歌曲!
处理流程:
1️⃣ 从您的音频中提取旋律...
2️⃣ 转换为MIDI记谱...
3️⃣ 生成完整编曲...
4️⃣ 渲染最终歌曲...
⏱️ 预计时间:2-5分钟
设置:
• 风格:{style}
• 情绪:{mood}
• 时长:{duration}秒
正在处理... 🎧
处理完成时
✅ 您的歌曲已就绪!
📁 输出:{output_path}
🎼 格式:{format}
⏱️ 时长:{actual_duration}秒
已完成的操作:
• 从您的哼唱中提取了{note_count}个音符
• 生成了{instrument_count}条乐器轨道
• 应用了{style}风格和{mood}情绪
💡 您可以:
• 调整风格/情绪并重新生成
• 导出为MIDI在DAW中编辑
• 尝试不同的AI模型以获得变化
交互示例
示例1:用户上传哼唱音频
用户:[上传哼唱音频]
AI:🎵 我将把您的哼唱转化为完整歌曲!
处理流程:
1️⃣ 从您的音频中提取旋律...
2️⃣ 转换为MIDI记谱...
3️⃣ 生成完整编曲...
4️⃣ 渲染最终歌曲...
⏱️ 预计时间:2-5分钟
您想要什么风格?
• 流行(默认)
• 摇滚
• 爵士
• 古典
• 电子
示例2:用户指定风格
用户:把这个哼唱变成爵士歌曲
AI:🎷 爵士风格转换即将开始!
正在以爵士风格处理您的哼唱:
• 摇摆节奏
• 行走低音线
• 钢琴和弦
• 刷子鼓
[处理中...]
✅ 您的爵士歌曲已就绪!
📁 输出:~/Music/hum2songjazz20240321.mp3
示例3:用户需要MIDI输出
用户:能给我MIDI文件让我自己编辑吗?
AI:🎼 当然可以!
我将生成:
• 提取的MIDI(原始旋律)
• 优化后的MIDI(量化、清理)
• 完整编曲MIDI(所有乐器)
所有文件将保存在:~/Music/hum2song_export/
技术细节
音频处理
输入格式: WAV, MP3, M4A, FLAC, OGG
采样率: 自动转换为44.1kHz
声道: 单声道/立体声 → 处理时转为单声道
MIDI提取
模型: Basic Pitch(Spotify,ICASSP 2022)
音高范围: C1至C8
音符检测: 支持复音
时值分辨率: 10ms
音乐生成
ACE-Step模型:
- - 大小:1B参数(基础版),3B(大版)
- 训练:授权音乐数据集
- 输出:44.1kHz立体声
- 延迟:在M1 Mac上约1秒生成1秒音频
SoundFont合成:
局限性
- - 需要本地Python环境配置
- ACE-Step基础模型需要约4GB内存
- 处理时间:2分钟歌曲约需2-5分钟
- 质量取决于哼唱的清晰度
- 复杂和声可能无法完全捕捉
隐私与安全
✅ 所有处理均在本地进行 - 您的音频永远不会离开您的机器
✅ 无需云服务 - 无需API密钥或外部上传
✅ 开源工具 - Basic Pitch, ACE-Step, Pretty MIDI
✅ 无数据收集 - 不会记录或传输任何内容
参考资料
- - basic-pitch.md - 音频转MIDI提取
- ace-step.md - AI音乐生成
- pretty_midi.md - MIDI处理
- librosa.md - 音频分析工具
技术信息
hum2song |
|
版本 | 3.0.4 |
|
类别 | 音频/音乐生成 |
|
标签 | 音乐, 音频, MIDI, AI生成,