add colab notebook

This commit is contained in:
謬紗特 2023-03-12 15:59:50 +08:00 committed by GitHub
parent c092d25716
commit 13a6a645fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 43 deletions

View File

@ -13,26 +13,25 @@
## Model Introduction
The singing voice conversion model uses [Content Vec](https://github.com/auspicious3000/contentvec) to extract content features and input them into the visinger2 model to synthesize the target sound.
The singing voice conversion model uses SoftVC content encoder to extract source audio speech features, and inputs them together with F0 to replace the original text input to achieve the effect of song conversion. At the same time, the vocoder is changed to [NSF HiFiGAN](https://github.com/openvpi/DiffSinger/tree/refactor/modules/nsf_hifigan) to solve the problem of sound interruption.
### Version 4.0 v2 Update
### 4.0 v2 update content
- The model architecture has been completely modified to [visinger2](https://github.com/zhangyongmao/VISinger2) architecture.
- Other than that, it is identical to version 4.0.
+ The model architecture is completely change to [visinger2](https://github.com/zhangyongmao/VISinger2)
+ Others are exactly the same as [4.0](https://github.com/svc-develop-team/so-vits-svc/tree/4.0).
### Version 4.0 v2 Features
### 4.0 v2 features
- It has some improvements in certain scenarios compared to version 4.0 (such as breathing and electric noise problems in some scenarios).
- However, it also has some regression in certain scenarios. For example, the effect trained on the Meowth dataset is not as good as version 4.0, and sometimes it synthesizes very strange sounds.
- Whether to use the old version or v2 is up to personal preference. You can try the demos below and compare the results to make a decision.
- 4.0-v2 is the last version of sovits, and there will be no further updates. After basic validation without significant bugs, sovits will be archived.
+ It is better than 4.0 in some scenes.For example, the current sound in the breath sound
+ But there is also a certain retrogression in some scene. For example, training with data from streaming of vtubers is not as good as [4.0](https://github.com/svc-develop-team/so-vits-svc/tree/4.0). Also in some cases it will turn out a terrible sound.
+ [4.0-v2](https://github.com/svc-develop-team/so-vits-svc/tree/4.0-v2) is the last version of sovits, there is no more update in the future.
## Note
- The entire process of 4.0-v2 is the same as 4.0, with the same environment and data preprocessed by 4.0 that can be directly used.
- The difference between 4.0-v2 and 4.0 is that:
- The model is **completely** non-universal. The old model cannot be used, and a completely new pre-trained model is also required. Please make sure that you have loaded the correct pre-trained model, otherwise the training time will be extremely long!
- The structure of the config file is very different. Do not use the old config. If using the 4.0 dataset, only execute the "preprocess_flist_config.py" step to generate a new config.
+ [4.0-v2](https://github.com/svc-develop-team/so-vits-svc/tree/4.0-v2) and [4.0](https://github.com/svc-develop-team/so-vits-svc/tree/4.0) are almost identical in process, which include preprocessing and requirements
+ The difference from 4.0 is:
+ The models is **completely different**. Check the version of the pretrained models if you are using them.
+ The structure of config file changed a lot. You can only run `python preprocess_flist_config.py` to generate new `config.json` if you are using preprocessed dataset from 4.0.
## Pre-trained Model Files
@ -150,7 +149,7 @@ The existing steps before clustering do not need to be changed. All you need to
- Specify "cluster_model_path" in inference_main.
- Specify "cluster_infer_ratio" in inference_main, where 0 means not using clustering at all, 1 means only using clustering, and usually 0.5 is sufficient.
### [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1kv-3y2DmZo0uya8pEr1xk7cSB-4e_Pct?usp=sharing) [sovits4 for colab.ipynb](https://colab.research.google.com/drive/1kv-3y2DmZo0uya8pEr1xk7cSB-4e_Pct?usp=sharing)
### [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/18KxJs7FCPjlTY2l0QUbDNfZnLrS9hL4m?usp=sharing) [sovits4v2 for colab.ipynb](https://colab.research.google.com/drive/18KxJs7FCPjlTY2l0QUbDNfZnLrS9hL4m?usp=sharing)
## Exporting to Onnx
@ -186,4 +185,4 @@ Note: For Hubert Onnx models, please use the models provided by MoeSS. Currently
##### 第一千零二十七条
【作品侵害名誉权】行为人发表的文学、艺术作品以真人真事或者特定人为描述对象,含有侮辱、诽谤内容,侵害他人名誉权的,受害人有权依法请求该行为人承担民事责任。
行为人发表的文学、艺术作品不以特定人为描述对象,仅其中的情节与该特定人的情况相似的,不承担民事责任。
行为人发表的文学、艺术作品不以特定人为描述对象,仅其中的情节与该特定人的情况相似的,不承担民事责任。

View File

@ -1,56 +1,66 @@
# SoftVC VITS Singing Voice Conversion
## 使用规约
1. 请自行解决数据集的授权问题任何由于使用非授权数据集进行训练造成的问题需自行承担全部责任和一切后果与sovits无关
2. 任何发布到视频平台的基于sovits制作的视频都必须要在简介明确指明用于变声器转换的输入源歌声、音频例如使用他人发布的视频/音频,通过分离的人声作为输入源进行转换的,必须要给出明确的原视频、音乐链接;若使用是自己的人声,或是使用其他歌声合成引擎合成的声音作为输入源进行转换的,也必须在简介加以说明。
3. 由输入源造成的侵权问题需自行承担全部责任和一切后果。使用其他商用歌声合成软件作为输入源时,请确保遵守该软件的使用条例,注意,许多歌声合成引擎使用条例中明确指明不可用于输入源进行转换!
[**English**](./README.md) | [**中文简体**](./README_zh_CN.md)
## 使用规约
1. 本项目是基于学术交流目的建立,仅供交流与学习使用,并非为生产环境准备,请自行解决数据集的授权问题,任何由于使用非授权数据集进行训练造成的问题,需自行承担全部责任和一切后果!
2. 任何发布到视频平台的基于 sovits 制作的视频,都必须要在简介明确指明用于变声器转换的输入源歌声、音频,例如:使用他人发布的视频 / 音频,通过分离的人声作为输入源进行转换的,必须要给出明确的原视频、音乐链接;若使用是自己的人声,或是使用其他歌声合成引擎合成的声音作为输入源进行转换的,也必须在简介加以说明。
3. 由输入源造成的侵权问题需自行承担全部责任和一切后果。使用其他商用歌声合成软件作为输入源时,请确保遵守该软件的使用条例,注意,许多歌声合成引擎使用条例中明确指明不可用于输入源进行转换!
4. 继续使用视为已同意本仓库 README 所述相关条例,本仓库 README 已进行劝导义务,不对后续可能存在问题负责。
5. 如将本仓库代码二次分发,或将由此项目产出的任何结果公开发表 (包括但不限于视频网站投稿),请注明原作者及代码来源 (此仓库)。
6. 如果将此项目用于任何其他企划,请提前联系并告知本仓库作者,十分感谢。
## 模型简介
歌声音色转换模型,使用[Content Vec](https://github.com/auspicious3000/contentvec) 提取内容特征输入visinger2模型合成目标声音
### 4.0 v2版本更新内容
+ 模型架构完全修改成[visinger2](https://github.com/zhangyongmao/VISinger2) 架构
+ 其他和4.0完全一致
### 4.0 v2版本特点
+ 在部分场景下比4.0有一定提升(例如部分场景的呼吸音电流音问题)
+ 但也有部分场景效果也有一定倒退例如在猫雷数据上训练出来效果并不如4.0,而且在部分情况会合成出很鬼畜的声音
+ 至于炼老的还是v2 可以自己尝试下面的demo和4.0分支上的demo后对比决定
+ 4.0-v2是sovits的最后一个版本之后不会再有更新在基本验证没有大的bug后sovits即将Archive
在线demo[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/innnky/sovits4.0-v2)
+ 4.0-v2是sovits的最后一个版本之后不会再有更新
## 注意
+ 4.0-v2全部流程与4.0相同环境与4.0相同4.0预处理完成的数据和环境可以直接用
+ 与4.0不同的地方在于:
+ 模型**完全** 不通用,旧模型不可使用,底模也需要使用全新的底模, 请确保你加载了正确的底模否则训练时间会究极长!
+ config文件结构很不一样不要使用老的config如果是使用4.0的数据集则只需要执行preprocess_flist_config.py这一步生成新的config
## 预先下载的模型文件
#### **必须项**
+ contentvec [checkpoint_best_legacy_500.pt](https://ibm.box.com/s/z1wgl1stco8ffooyatzdwsqn2psd9lrr)
+ 放在`hubert`目录下
+ 预训练底模文件: [G_0.pth](https://huggingface.co/innnky/sovits_pretrained/resolve/main/sovits4.0-v2/G_0.pth) 与 [D_0.pth](https://huggingface.co/innnky/sovits_pretrained/resolve/main/sovits4.0-v2/D_0.pth)
+ 放在`logs/44k`目录下
+ 预训练底模训练数据集覆盖男女生常见音域,可以认为是相对通用的底模
```shell
# 一键下载
# contentvec
wget -P hubert/ http://obs.cstcloud.cn/share/obs/sankagenkeshi/checkpoint_best_legacy_500.pt
# 也可手动下载放在hubert目录
# G与D预训练模型:
wget -P logs/44k/ https://huggingface.co/innnky/sovits_pretrained/resolve/main/sovits4.0-v2/G_0.pth
wget -P logs/44k/ https://huggingface.co/innnky/sovits_pretrained/resolve/main/sovits4.0-v2/D_0.pth
```shell
# contentvec
http://obs.cstcloud.cn/share/obs/sankagenkeshi/checkpoint_best_legacy_500.pt
# 也可手动下载放在hubert目录
```
[//]: # (## colab一键数据集制作、训练脚本)
#### **可选项(强烈建议使用)**
[//]: # ([![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/19fxpo-ZoL_ShEUeZIZi6Di-YioWrEyhR#scrollTo=0gQcIZ8RsOkn))
+ 预训练底模文件: `G_0.pth` `D_0.pth`
+ 放在`logs/44k`目录下
从svc-develop-team(待定)或任何其他地方获取
虽然底模一般不会引起什么版权问题,但还是请注意一下,比如事先询问作者,又或者作者在模型描述中明确写明了可行的用途
后面部分的readme和4.0一样了,没有变化
## 数据集准备
仅需要以以下文件结构将数据集放入dataset_raw目录即可
```shell
dataset_raw
├───speaker0
@ -63,31 +73,37 @@ dataset_raw
└───xxx7-xxx007.wav
```
## 数据预处理
1. 重采样至 44100hz
```shell
python resample.py
```
```
2. 自动划分训练集 验证集 测试集 以及自动生成配置文件
```shell
python preprocess_flist_config.py
```
3. 生成hubert与f0
```shell
python preprocess_hubert_f0.py
```
执行完以上步骤后 dataset 目录便是预处理完成的数据可以删除dataset_raw文件夹了
## 训练
```shell
python train.py -c configs/config.json -m 44k
```
训练时会自动清除老的模型只保留最新3个模型如果想防止过拟合需要自己手动备份模型记录点,或修改配置文件keep_ckpts 0为永不清除
## 推理
使用 [inference_main.py](inference_main.py)
截止此处4.0使用方法训练、推理和3.0完全一致,没有任何变化(推理增加了命令行支持)
@ -96,6 +112,7 @@ python train.py -c configs/config.json -m 44k
# 例
python inference_main.py -m "logs/44k/G_30400.pth" -c "configs/config.json" -n "君の知らない物語-src.wav" -t 0 -s "nen"
```
必填项部分
+ -m, --model_path模型路径。
+ -c, --config_path配置文件路径。
@ -109,15 +126,21 @@ python inference_main.py -m "logs/44k/G_30400.pth" -c "configs/config.json" -n "
+ -cr, --cluster_infer_ratio聚类方案占比范围 0-1若没有训练聚类模型则填 0 即可。
## 可选项
如果前面的效果已经满意,或者没看明白下面在讲啥,那后面的内容都可以忽略,不影响模型使用。(这些可选项影响比较小,可能在某些特定数据上有点效果,但大部分情况似乎都感知不太明显)
如果前面的效果已经满意,或者没看明白下面在讲啥,那后面的内容都可以忽略,不影响模型使用(这些可选项影响比较小,可能在某些特定数据上有点效果,但大部分情况似乎都感知不太明显)
### 自动f0预测
4.0模型训练过程会训练一个f0预测器对于语音转换可以开启自动音高预测如果效果不好也可以使用手动的但转换歌声时请不要启用此功能会严重跑调
+ 在inference_main中设置auto_predict_f0为true即可
### 聚类音色泄漏控制
介绍:聚类方案可以减小音色泄漏,使得模型训练出来更像目标的音色(但其实不是特别明显),但是单纯的聚类方案会降低模型的咬字(会口齿不清)(这个很明显),本模型采用了融合的方式,
可以线性控制聚类方案与非聚类方案的占比,也就是可以手动在"像目标音色" 和 "咬字清晰" 之间调整比例,找到合适的折中点。
使用聚类前面的已有步骤不用进行任何的变动,只需要额外训练一个聚类模型,虽然效果比较有限,但训练成本也比较低
+ 训练过程:
+ 使用cpu性能较好的机器训练据我的经验在腾讯云6核cpu训练每个speaker需要约4分钟即可完成训练
+ 执行python cluster/train_cluster.py ,模型的输出会在 logs/44k/kmeans_10000.pt
@ -125,7 +148,10 @@ python inference_main.py -m "logs/44k/G_30400.pth" -c "configs/config.json" -n "
+ inference_main中指定cluster_model_path
+ inference_main中指定cluster_infer_ratio0为完全不使用聚类1为只使用聚类通常设置0.5即可
### [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/18KxJs7FCPjlTY2l0QUbDNfZnLrS9hL4m?usp=sharing) [sovits4v2 for colab.ipynb](https://colab.research.google.com/drive/18KxJs7FCPjlTY2l0QUbDNfZnLrS9hL4m?usp=sharing)
## Onnx导出
使用 [onnx_export.py](onnx_export.py)
+ 新建文件夹:`checkpoints` 并打开
+ 在`checkpoints`文件夹中新建一个文件夹作为项目文件夹,文件夹名为你的项目名称,比如`aziplayer`
@ -133,8 +159,29 @@ python inference_main.py -m "logs/44k/G_30400.pth" -c "configs/config.json" -n "
+ 将 [onnx_export.py](onnx_export.py) 中`path = "NyaruTaffy"` 的 `"NyaruTaffy"` 修改为你的项目名称,`path = "aziplayer"`
+ 运行 [onnx_export.py](onnx_export.py)
+ 等待执行完毕,在你的项目文件夹下会生成一个`model.onnx`,即为导出的模型
### Onnx模型支持的UI
+ [MoeSS](https://github.com/NaruseMioShirakana/MoeSS)
### Onnx模型支持的UI
+ [MoeSS](https://github.com/NaruseMioShirakana/MoeSS)
+ 我去除了所有的训练用函数和一切复杂的转置一行都没有保留因为我认为只有去除了这些东西才知道你用的是Onnx
+ 注意Hubert Onnx模型请使用MoeSS提供的模型目前无法自行导出fairseq中Hubert有不少onnx不支持的算子和涉及到常量的东西在导出时会报错或者导出的模型输入输出shape和结果都有问题
[Hubert4.0](https://huggingface.co/NaruseMioShirakana/MoeSS-SUBModel)
[Hubert4.0](https://huggingface.co/NaruseMioShirakana/MoeSS-SUBModel)
## 一些法律条例参考
#### 《民法典》
##### 第一千零一十九条
任何组织或者个人不得以丑化、污损,或者利用信息技术手段伪造等方式侵害他人的肖像权。未经肖像权人同意,不得制作、使用、公开肖像权人的肖像,但是法律另有规定的除外。
未经肖像权人同意,肖像作品权利人不得以发表、复制、发行、出租、展览等方式使用或者公开肖像权人的肖像。
对自然人声音的保护,参照适用肖像权保护的有关规定。
##### 第一千零二十四条
【名誉权】民事主体享有名誉权。任何组织或者个人不得以侮辱、诽谤等方式侵害他人的名誉权。
##### 第一千零二十七条
【作品侵害名誉权】行为人发表的文学、艺术作品以真人真事或者特定人为描述对象,含有侮辱、诽谤内容,侵害他人名誉权的,受害人有权依法请求该行为人承担民事责任。
行为人发表的文学、艺术作品不以特定人为描述对象,仅其中的情节与该特定人的情况相似的,不承担民事责任。