上传原始歌曲,输入新歌词,保持原有旋律和音色替换歌词。
- 🎤 人声分离: 使用 Demucs 将歌曲分离为人声和伴奏
- 🎼 旋律提取: 从原唱中提取音高曲线(F0)
- 📝 歌词对齐: 用 WhisperX 自动对齐歌词时间
- 🎶 歌声合成: 用 DiffSinger 根据新歌词和原旋律合成新歌声
- 🎭 音色克隆: 用 RVC 将新歌声转换为原唱音色(可选)
- 🔊 混音输出: 将新人声与原伴奏混合生成最终音频
| 组件 | 用途 | 来源 |
|---|---|---|
| Demucs | 人声分离 | Meta |
| DiffSinger | 歌声合成 | OpenVPI |
| RVC | 音色转换 | RVC-Project |
| WhisperX | 歌词转录+对齐 | m-bain |
| Gradio | Web 界面 | Gradio |
pip install -r requirements.txt# 下载所有模型
python scripts/download_models.py --all
# 或按需下载
python scripts/download_models.py --rmvpe # 音高提取模型
python scripts/download_models.py --diffsinger # 歌声合成模型
python scripts/download_models.py --rvc # RVC 基础模型python webui/app.py访问 http://localhost:7860 即可使用。
from pipeline import LyricsReplacer
replacer = LyricsReplacer()
result = replacer.replace_lyrics(
input_path="song.mp3",
new_lyrics="新的歌词内容",
output_dir="output",
)
print(f"输出文件: {result.output_path}")VoiceCraft/
├── main.py # CLI + WebUI 双模式入口
├── pipeline/ # 核心 Pipeline
│ ├── __init__.py
│ ├── vocal_separator.py # 人声分离(Demucs)
│ ├── melody_extractor.py # 旋律提取(RMVPE/CREPE)
│ ├── lyrics_aligner.py # 歌词对齐(WhisperX)
│ ├── singer.py # 歌声合成(DiffSinger + fallback)
│ ├── voice_converter.py # 音色转换(RVC)
│ ├── rvc_inference.py # RVC 推理引擎
│ ├── rvc_arch.py # RVC 模型架构
│ ├── mixer.py # 混音输出
│ └── lyrics_replacer.py # 端到端 Pipeline
├── webui/ # Web 界面
│ ├── app.py # Gradio 主应用
│ └── tabs/
│ └── lyrics_replace.py # 换歌词 Tab
├── scripts/
│ └── download_models.py # 模型下载脚本
├── tests/
│ └── test_pipeline.py # 集成测试
├── configs/
│ └── default.yaml # 默认配置
├── checkpoints/ # 模型文件(需下载)
├── output/ # 输出目录
├── requirements.txt
└── README.md
# 运行所有单元测试
python tests/test_pipeline.py
# 测试单个模块
python tests/test_pipeline.py --module mixer
python tests/test_pipeline.py --module melody
python tests/test_pipeline.py --module singer
# 端到端测试
python tests/test_pipeline.py --e2e --input song.mp3 --lyrics "新歌词"编辑 configs/default.yaml 调整参数:
separation:
model: "htdemucs" # Demucs 模型
device: "cuda" # cuda 或 cpu
melody:
method: "rmvpe" # 音高提取方法
alignment:
language: "zh" # 语言
voice_conversion:
model_path: "" # RVC 模型路径
f0_up_key: 0 # 音高偏移(半音)
mixing:
vocal_volume: 1.0 # 人声音量
instrumental_volume: 1.0 # 伴奏音量输入: 原始歌曲.mp3 + 新歌词.txt
│
┌────┴────┐
▼ ▼
Demucs Demucs
(分离) (分离)
│ │
▼ ▼
伴奏.wav 人声.wav
│ │
│ ┌────┴────┐
│ ▼ ▼
│ RMVPE WhisperX
│ (F0) (歌词+时间)
│ │ │
│ └────┬────┘
│ ▼
│ DiffSinger
│ (新词+原旋律→基础歌声)
│ │
│ ▼
│ RVC 音色转换(可选)
│ (→原唱歌声)
│ │
└────┬────┘
▼
混音
│
▼
输出: 新歌曲.wav
- 模型下载: DiffSinger 和 RVC 模型需要单独下载或训练
- GPU 要求: 推荐使用 NVIDIA GPU(CUDA),CPU 也可运行但较慢
- 音质: 最终效果取决于模型质量和参数调优
- 语言: 目前主要支持中文,英文和日文需要对应语言模型
MIT License