基于VITS的端到端歌声转换开源项目
whisper-vits-svc是一个开源的端到端歌声转换项目,基于VITS模型架构。该项目支持多说话人转换,可混合创建新音色,并能处理带轻伴奏的声音。它集成了Whisper、BigVGAN等技术,提高了抗噪性和音质。项目面向深度学习入门者,需要Python和PyTorch基础。目前不支持实时转换,训练需要至少6GB显存。
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/PlayVoice/so-vits-svc-5.0">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/PlayVoice/so-vits-svc-5.0">
<img alt="GitHub issues" src="https://img.shields.io/github/issues/PlayVoice/so-vits-svc-5.0">
<img alt="GitHub" src="https://img.shields.io/github/license/PlayVoice/so-vits-svc-5.0">
bigvgan-mix-v2 分支音频质量较好
RoFormer-HiFTNet 分支推理速度较快
不再更新
</div>训练至少需要6GB显存
支持多说话人
通过说话人混合创建独特说话人
甚至可以转换带有轻伴奏的声音
可以使用Excel编辑F0
https://github.com/PlayVoice/so-vits-svc-5.0/assets/16432329/6a09805e-ab93-47fe-9a14-9cbc1e0e7c3a
由@ShadowVap提供支持
特性 | 来源 | 状态 | 功能 |
---|---|---|---|
whisper | OpenAI | ✅ | 强抗噪能力 |
bigvgan | NVIDA | ✅ | 别名和蛇形 |
natural speech | Microsoft | ✅ | 减少发音错误 |
neural source-filter | Xin Wang | ✅ | 解决音频F0不连续问题 |
pitch quantization | Xin Wang | ✅ | 量化F0用于嵌入 |
speaker encoder | ✅ | 音色编码和聚类 | |
GRL for speaker | Ubisoft | ✅ | 防止编码器泄漏音色 |
SNAC | Samsung | ✅ | VITS的一次性克隆 |
SCLN | Microsoft | ✅ | 改进克隆 |
Diffusion | HuaWei | ✅ | 提高音质 |
PPG perturbation | 本项目 | ✅ | 提高抗噪能力和去音色 |
HuBERT perturbation | 本项目 | ✅ | 提高抗噪能力和去音色 |
VAE perturbation | 本项目 | ✅ | 提高音质 |
MIX encoder | 本项目 | ✅ | 提高转换稳定性 |
USP infer | 本项目 | ✅ | 提高转换稳定性 |
HiFTNet | 哥伦比亚大学 | ✅ | NSF-iSTFTNet加速推理 |
RoFormer | 追一科技 | ✅ | 旋转位置嵌入 |
由于使用了数据扰动,训练时间比其他项目更长。
USP : 推理时的无声和静音带音高
安装 PyTorch。
安装项目依赖
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
注意:whisper已经内置,不要再次安装,否则会导致冲突和错误
下载音色编码器:Speaker-Encoder by @mueller91,将 best_model.pth.tar
放入 speaker_pretrain/
。
下载whisper模型 whisper-large-v2。确保下载 large-v2.pt
,将其放入 whisper_pretrain/
。
下载 hubert_soft 模型,将 hubert-soft-0d54a1f4.pt
放入 hubert_pretrain/
。
下载音高提取器 crepe full,将 full.pth
放入 crepe/assets
。
注意:crepe full.pth 大小为84.9 MB,而不是6kb
下载预训练模型 sovits5.0.pretrain.pth,并将其放入 vits_pretrain/
。
python svc_inference.py --config configs/base.yaml --model ./vits_pretrain/sovits5.0.pretrain.pth --spk ./configs/singers/singer0001.npy --wave test.wav
必要的预处理:
dataset_raw
目录。dataset_raw
├───speaker0
│ ├───000001.wav
│ ├───...
│ └───000xxx.wav
└───speaker1
├───000001.wav
├───...
└───000xxx.wav
python svc_preprocessing.py -t 2
-t
:线程数,最大数量不应超过CPU核心数,通常2就足够了。
预处理完成后,你将得到以下结构的输出。
data_svc/
└── waves-16k
│ └── speaker0
│ │ ├── 000001.wav
│ │ └── 000xxx.wav
│ └── speaker1
│ ├── 000001.wav
│ └── 000xxx.wav
└── waves-32k
│ └── speaker0
│ │ ├── 000001.wav
│ │ └── 000xxx.wav
│ └── speaker1
│ ├── 000001.wav
│ └── 000xxx.wav
└── pitch
│ └── speaker0
│ │ ├── 000001.pit.npy
│ │ └── 000xxx.pit.npy
│ └── speaker1
│ ├── 000001.pit.npy
│ └── 000xxx.pit.npy
└── hubert
│ └── speaker0
│ │ ├── 000001.vec.npy
│ │ └── 000xxx.vec.npy
│ └── speaker1
│ ├── 000001.vec.npy
│ └── 000xxx.vec.npy
└── whisper
│ └── speaker0
│ │ ├── 000001.ppg.npy
│ │ └── 000xxx.ppg.npy
│ └── speaker1
│ ├── 000001.ppg.npy
│ └── 000xxx.ppg.npy
└── speaker
│ └── speaker0
│ │ ├── 000001.spk.npy
│ │ └── 000xxx.spk.npy
│ └── speaker1
│ ├── 000001.spk.npy
│ └── 000xxx.spk.npy
└── singer
│ ├── speaker0.spk.npy
│ └── speaker1.spk.npy
|
└── indexes
├── speaker0
│ ├── some_prefix_hubert.index
│ └── some_prefix_whisper.index
└── speaker1
├── hubert.index
└── whisper.index
重采样
./data_svc/waves-16k
中生成采样率为 16000Hz 的音频python prepare/preprocess_a.py -w ./dataset_raw -o ./data_svc/waves-16k -s 16000
./data_svc/waves-32k
中生成采样率为 32000Hz 的音频python prepare/preprocess_a.py -w ./dataset_raw -o ./data_svc/waves-32k -s 32000
使用 16K 音频提取音高
python prepare/preprocess_crepe.py -w data_svc/waves-16k/ -p data_svc/pitch
使用 16K 音频提取 ppg
python prepare/preprocess_ppg.py -w data_svc/waves-16k/ -p data_svc/whisper
使用 16K 音频提取 hubert
python prepare/preprocess_hubert.py -w data_svc/waves-16k/ -v data_svc/hubert
使用 16k 音频提取音色编码
python prepare/preprocess_speaker.py data_svc/waves-16k/ data_svc/speaker
提取音色编码的平均值用于推理;也可以替换生成训练索引中的单个音频音色,作为说话人的统一音色用于训练
python prepare/preprocess_speaker_ave.py data_svc/speaker/ data_svc/singer
使用 32k 音频提取线性谱
python prepare/preprocess_spec.py -w data_svc/waves-32k/ -s data_svc/specs
使用 32k 音频生成训练索引
python prepare/preprocess_train.py
训练文件调试
python prepare/preprocess_zzz.py
如果基于预训练模型进行微调,需要下载预训练模型:sovits5.0.pretrain.pth。将预训练模型放在项目根目录下,修改 configs/base.yaml
中的这一行
pretrain: "./vits_pretrain/sovits5.0.pretrain.pth"
并适当调整学习率,例如 5e-5。
batch_size
:对于 6G 显存的 GPU,推荐值为 6,8 也可以工作但步骤速度会慢很多。
开始训练
python svc_trainer.py -c configs/base.yaml -n sovits5.0
恢复训练
python svc_trainer.py -c configs/base.yaml -n sovits5.0 -p chkpt/sovits5.0/sovits5.0_***.pt
日志可视化
tensorboard --logdir logs/
导出推理模型:文本编码器、Flow 网络、解码器网络
python svc_export.py --config configs/base.yaml --checkpoint_path chkpt/sovits5.0/***.pt
推理
f0
,只需运行以下命令。python svc_inference.py --config configs/base.yaml --model sovits5.0.pth --spk ./data_svc/singer/your_singer.spk.npy --wave test.wav --shift 0
f0
,请按以下步骤操作:
test.vec.npy
。python whisper/inference.py -w test.wav -p test.ppg.npy
python hubert/inference.py -w test.wav -v test.vec.npy
python pitch/inference.py -w test.wav -p test.csv
python svc_inference.py --config configs/base.yaml --model sovits5.0.pth --spk ./data_svc/singer/your_singer.spk.npy --wave test.wav --ppg test.ppg.npy --vec test.vec.npy --pit test.csv --shift 0
注意事项
当指定 --ppg
时,同一音频多次推理时可以避免重复提取音频内容编码;如果不指定,将自动提取;
当指定 --vec
时,同一音频多次推理时可以避免重复提取音频内容编码;如果不指定,将自动提取;
当指定 --pit
时,可以加载手动调整后的 F0 参数;如果不指定,将自动提取;
在当前目录生成文件:svc_out.wav
参数参考
参数 | --config | --model | --spk | --wave | --ppg | --vec | --pit | --shift |
---|---|---|---|---|---|---|---|---|
名称 | 配置路径 | 模型路径 | 说话人 | 波形输入 | 波形ppg | 波形hubert | 波形音高 | 音高偏移 |
通过 vad 后处理
python svc_inference_post.py --ref test.wav --svc svc_out.wav --out svc_out_post.wav
为了提高生成音色的稳定性,可以使用 Retrieval-based-Voice-Conversion 仓库中描述的方法。该方法包括两个步骤:
对 hubert 和 whisper 特征训练检索索引 使用默认设置运行训练:
python svc_train_retrieval.py
如果向量数量超过 200,000,将使用 MiniBatchKMeans 算法压缩到 10,000。 您可以使用命令行选项更改这些设置:
usage: 创建特征检索的 faiss 索引 [-h] [--debug] [--prefix PREFIX] [--speakers SPEAKERS [SPEAKERS ...]] [--compress-features-after COMPRESS_FEATURES_AFTER]
[--n-clusters N_CLUSTERS] [--n-parallel N_PARALLEL]
选项:
-h, --help 显示此帮助信息并退出
--debug
--prefix PREFIX 为索引文件名添加前缀
--speakers SPEAKERS [SPEAKERS ...]
创建索引的说话人名称。默认为 data_svc 中的所有说话人
--compress-features-after COMPRESS_FEATURES_AFTER
如果特征数量大于该值,则使用 MiniBatchKMeans 压缩特征向量。
--n-clusters N_CLUSTERS
特征将被压缩到的中心点数量
--n-parallel N_PARALLEL
MinibatchKmeans 的并行作业数。默认为 cpus-1
压缩训练向量可以加快索引推理速度,但会降低检索质量。 只有在您确实有大量向量时才使用向量计数压缩。
生成的索引将存储在 "indexes" 文件夹中,如下所示:
data_svc
...
└── indexes
├── speaker0
│ ├── some_prefix_hubert.index
│ └── some_prefix_whisper.index
└── speaker1
├── hubert.index
└── whisper.index
在推理阶段,以一定比例添加 n 个最接近的特征到 vits 模型中 使用以下设置启用特征检索:
python svc_inference.py --config configs/base.yaml --model sovits5.0.pth --spk ./data_svc/singer/your_singer.spk.npy --wave test.wav --shift 0 \
--enable-retrieval \
--retrieval-ratio 0.5 \
--n-retrieval-vectors 3
为了获得更好的检索效果,可以尝试循环使用不同的参数:--retrieval-ratio
和 --n-retrieval-vectors
如果您有多组索引,可以通过参数 --retrieval-index-prefix
指定特定的一组
您可以使用参数 --hubert-index-path
和 --whisper-index-path
明确指定 hubert 和 whisper 索引的路径
命名纯属巧合:average -> ave -> eva,eve(eva) 代表概念和繁衍
python svc_eva.py
eva_conf = { './configs/singers/singer0022.npy': 0, './configs/singers/singer0030.npy': 0, './configs/singers/singer0047.npy': 0.5, './configs/singers/singer0051.npy': 0.5, }
生成的歌手文件将是 eva.spk.npy
。
https://github.com/facebookresearch/speech-resynthesis 论文 https://github.com/jaywalnut310/vits 论文
https://github.com/openai/whisper/ 论文
https://github.com/NVIDIA/BigVGAN 论文
https://github.com/mindslab-ai/univnet 论文
https://github.com/nii-yamagishilab/project-NN-Pytorch-scripts/tree/master/project/01-nsf
https://github.com/huawei-noah/Speech-Backbones/tree/main/Grad-TTS
https://github.com/brentspell/hifi-gan-bwe
https://github.com/mozilla/TTS
https://github.com/bshall/soft-vc
https://github.com/maxrmorrison/torchcrepe
https://github.com/MoonInTheRiver/DiffSinger
https://github.com/OlaWod/FreeVC 论文
https://github.com/yl4579/HiFTNet 论文
SNAC:基于流的架构中的说话人归一化仿射耦合层,用于零样本多说话人文本转语音
通过聆听学习唱歌:通过从语音录音中无监督学习构建可控虚拟歌手
使用未标注外部数据进行对抗性说话人解耦,用于基于自监督表示的语音转换
RoFormer:具有旋转位置嵌入的增强型Transformer
https://github.com/auspicious3000/contentvec/blob/main/contentvec/data/audio/audio_utils_1.py
https://github.com/revsic/torch-nansy/blob/main/utils/augment/praat.py
https://github.com/revsic/torch-nansy/blob/main/utils/augment/peq.py
https://github.com/biggytruck/SpeechSplit2/blob/main/utils.py
https://github.com/OlaWod/FreeVC/blob/main/preprocess_sr.py
https://github.com/Francis-Komizu/Sovits
2022.04.12 https://mp.weixin.qq.com/s/autNBYCsG4_SvWt2-Ll_zA
2022.04.22 https://github.com/PlayVoice/VI-SVS
2022.07.26 https://mp.weixin.qq.com/s/qC4TJy-4EVdbpvK2cQb1TA
2022.09.08 https://github.com/PlayVoice/VI-SVC
字节跳动发布的AI编程神器IDE
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。