so-vits-svc/README.md

273 lines
17 KiB
Markdown
Raw Normal View History

2023-03-12 02:54:00 +00:00
# SoftVC VITS Singing Voice Conversion
2023-03-11 05:23:24 +00:00
2023-03-12 02:46:22 +00:00
[**English**](./README.md) | [**中文简体**](./README_zh_CN.md)
2023-03-20 11:07:59 +00:00
#### ✨ A fork with a greatly improved interface: [34j/so-vits-svc-fork](https://github.com/34j/so-vits-svc-fork)
2023-03-11 05:23:24 +00:00
2023-03-20 11:07:59 +00:00
#### ✨ A client supports real-time conversion: [w-okada/voice-changer](https://github.com/w-okada/voice-changer)
2023-04-11 13:25:29 +00:00
## Warning!!!
2023-04-11 13:24:55 +00:00
This project is an open source, offline project, and all members of SvcDevelopTeam and all developers and maintainers of this project (hereinafter referred to as contributors) have no control over this project. The contributor of this project has never provided any organization or individual with any form of assistance, including but not limited to data set extraction, data set processing, computing support, training support, infering, etc. Contributors to the project do not and cannot know what users are using the project for. Therefore, all AI models and synthesized audio based on the training of this project have nothing to do with the contributors of this project. All problems arising therefrom shall be borne by the user.
2023-03-20 11:07:59 +00:00
## 📏 Terms of Use
# Warning: Please solve the authorization problem of the dataset on your own. You shall be solely responsible for any problems caused by the use of non-authorized datasets for training and all consequences thereof.The repository and its maintainer, svc develop team, have nothing to do with the consequences!
1. This project is established for academic exchange purposes only and is intended for communication and learning purposes. It is not intended for production environments.
2023-03-11 05:23:24 +00:00
2. Any videos based on sovits that are published on video platforms must clearly indicate in the description that they are used for voice changing and specify the input source of the voice or audio, for example, using videos or audios published by others and separating the vocals as input source for conversion, which must provide clear original video or music links. If your own voice or other synthesized voices from other commercial vocal synthesis software are used as the input source for conversion, you must also explain it in the description.
3. You shall be solely responsible for any infringement problems caused by the input source. When using other commercial vocal synthesis software as input source, please ensure that you comply with the terms of use of the software. Note that many vocal synthesis engines clearly state in their terms of use that they cannot be used for input source conversion.
2023-04-11 13:24:55 +00:00
4. It is forbidden to use the project to engage in illegal activities, religious and political activities. The project developers firmly resist the above activities. If they do not agree with this article, the use of the project is prohibited.
5. Continuing to use this project is deemed as agreeing to the relevant provisions stated in this repository README. This repository README has the obligation to persuade, and is not responsible for any subsequent problems that may arise.
6. If you use this project for any other plan, please contact and inform the author of this repository in advance. Thank you very much.
2023-03-11 05:23:24 +00:00
2023-03-20 11:07:59 +00:00
## 🆕 Update!
2023-03-11 05:23:24 +00:00
2023-03-16 14:57:05 +00:00
> Updated the 4.0-v2 model, the entire process is the same as 4.0. Compared to 4.0, there is some improvement in certain scenarios, but there are also some cases where it has regressed. Please refer to the [4.0-v2 branch](https://github.com/svc-develop-team/so-vits-svc/tree/4.0-v2) for more information.
2023-04-15 13:51:38 +00:00
## 📝 4.0 Feature list of branches
| Branch | Feature | whether compatible with the main branch model |
| :-------------: | :----------: | :------------: |
| 4.0 | main branch | - |
| 4.0v2 | The VISinger2 model is used | incompatibility |
| 4.0-Vec768-Layer12 | The feature input is the Layer 12 Transformer output of the Content Vec | incompatibility |
2023-03-20 11:07:59 +00:00
## 📝 Model Introduction
2023-03-11 05:23:24 +00:00
2023-03-16 14:57:05 +00:00
The singing voice conversion model uses SoftVC content encoder to extract source audio speech features, then the vectors are directly fed into VITS instead of converting to a text based intermediate; thus the pitch and intonations are conserved. Additionally, the vocoder is changed to [NSF HiFiGAN](https://github.com/openvpi/DiffSinger/tree/refactor/modules/nsf_hifigan) to solve the problem of sound interruption.
2023-03-11 05:23:24 +00:00
2023-04-15 03:33:07 +00:00
### 🆕 4.0-Vec768-Layer12 Version Update Content
- Feature input is changed to [Content Vec](https://github.com/auspicious3000/contentvec) Transformer output of 12 layer, the branch is not compatible with 4.0 model
2023-04-08 17:07:12 +00:00
2023-03-24 15:13:44 +00:00
## 💬 About Python Version
2023-04-09 03:36:55 +00:00
After conducting tests, we believe that the project runs stably on `Python 3.8.9`.
2023-03-24 15:13:44 +00:00
2023-03-20 11:07:59 +00:00
## 📥 Pre-trained Model Files
2023-03-11 05:23:24 +00:00
2023-03-12 02:46:22 +00:00
#### **Required**
2023-03-11 05:23:24 +00:00
- ContentVec: [checkpoint_best_legacy_500.pt](https://ibm.box.com/s/z1wgl1stco8ffooyatzdwsqn2psd9lrr)
- Place it under the `hubert` directory
```shell
# contentvec
wget -P hubert/ http://obs.cstcloud.cn/share/obs/sankagenkeshi/checkpoint_best_legacy_500.pt
# Alternatively, you can manually download and place it in the hubert directory
```
2023-03-12 02:46:22 +00:00
#### **Optional(Strongly recommend)**
- Pre-trained model files: `G_0.pth` `D_0.pth`
- Place them under the `logs/44k` directory
Get them from svc-develop-team(TBD) or anywhere else.
2023-03-12 02:53:36 +00:00
Although the pretrained model generally does not cause any copyright problems, please pay attention to it. For example, ask the author in advance, or the author has indicated the feasible use in the description clearly.
2023-04-08 17:07:12 +00:00
#### **Optional(Select as Required)**
2023-04-09 03:36:55 +00:00
If you are using the NSF-HIFIGAN enhancer, you will need to download the pre-trained NSF-HIFIGAN model, or not if you do not need it.
2023-04-08 17:07:12 +00:00
- Pre-trained NSF-HIFIGAN Vocoder: [nsf_hifigan_20221211.zip](https://github.com/openvpi/vocoders/releases/download/nsf-hifigan-v1/nsf_hifigan_20221211.zip)
2023-04-09 03:36:55 +00:00
- Unzip and place the four files under the `pretrain/nsf_hifigan` directory
2023-04-08 17:07:12 +00:00
```shell
# nsf_hifigan
https://github.com/openvpi/vocoders/releases/download/nsf-hifigan-v1/nsf_hifigan_20221211.zip
# Alternatively, you can manually download and place it in the pretrain/nsf_hifigan directory
# URLhttps://github.com/openvpi/vocoders/releases/tag/nsf-hifigan-v1
```
2023-03-20 11:07:59 +00:00
## 📊 Dataset Preparation
2023-03-11 05:23:24 +00:00
Simply place the dataset in the `dataset_raw` directory with the following file structure.
2023-03-24 08:59:47 +00:00
```
2023-03-11 05:23:24 +00:00
dataset_raw
├───speaker0
│ ├───xxx1-xxx1.wav
│ ├───...
│ └───Lxx-0xx8.wav
└───speaker1
├───xx2-0xxx2.wav
├───...
└───xxx7-xxx007.wav
```
2023-03-24 08:59:47 +00:00
You can customize the speaker name.
```
dataset_raw
└───suijiSUI
├───1.wav
├───...
└───25788785-20221210-200143-856_01_(Vocals)_0_0.wav
```
2023-03-20 11:07:59 +00:00
## 🛠️ Preprocessing
2023-03-11 05:23:24 +00:00
2023-04-09 03:41:03 +00:00
### 0. Slice audio
2023-04-09 03:36:55 +00:00
Slice to `5s - 15s`, a bit longer is no problem. Too long may lead to `torch.cuda.OutOfMemoryError` during training or even pre-processing.
By using [audio-slicer-GUI](https://github.com/flutydeer/audio-slicer) or [audio-slicer-CLI](https://github.com/openvpi/audio-slicer)
2023-04-09 03:41:03 +00:00
In general, only the `Minimum Interval` needs to be adjusted. For statement audio it usually remains default. For singing audio it can be adjusted to `100` or even `50`.
2023-04-09 03:36:55 +00:00
After slicing, delete audio that is too long and too short.
2023-04-09 03:41:03 +00:00
### 1. Resample to 44100Hz and mono
2023-03-11 05:23:24 +00:00
```shell
python resample.py
```
2023-04-09 03:41:03 +00:00
### 2. Automatically split the dataset into training and validation sets, and generate configuration files.
2023-03-11 05:23:24 +00:00
```shell
python preprocess_flist_config.py
```
2023-04-09 03:41:03 +00:00
### 3. Generate hubert and f0
2023-03-11 05:23:24 +00:00
```shell
python preprocess_hubert_f0.py
```
After completing the above steps, the dataset directory will contain the preprocessed data, and the dataset_raw folder can be deleted.
2023-04-05 07:24:53 +00:00
#### You can modify some parameters in the generated config.json
* `keep_ckpts`: Keep the last `keep_ckpts` models during training. Set to `0` will keep them all. Default is `3`.
2023-04-05 07:26:59 +00:00
* `all_in_mem`: Load all dataset to RAM. It can be enabled when the disk IO of some platforms is too low and the system memory is **much larger** than your dataset.
2023-04-05 07:24:53 +00:00
2023-03-20 11:07:59 +00:00
## 🏋️‍♀️ Training
2023-03-11 05:23:24 +00:00
```shell
python train.py -c configs/config.json -m 44k
```
2023-03-20 11:07:59 +00:00
## 🤖 Inference
2023-03-11 05:23:24 +00:00
Use [inference_main.py](https://github.com/svc-develop-team/so-vits-svc/blob/4.0/inference_main.py)
```shell
# Example
python inference_main.py -m "logs/44k/G_30400.pth" -c "configs/config.json" -n "君の知らない物語-src.wav" -t 0 -s "nen"
```
Required parameters:
2023-04-05 11:01:30 +00:00
- `-m` | `--model_path`: path to the model.
- `-c` | `--config_path`: path to the configuration file.
- `-n` | `--clean_names`: a list of wav file names located in the raw folder.
- `-t` | `--trans`: pitch adjustment, supports positive and negative (semitone) values.
- `-s` | `--spk_list`: target speaker name for synthesis.
- `-cl` | `--clip`: voice forced slicing, set to 0 to turn off(default), duration in seconds.
2023-03-11 05:23:24 +00:00
Optional parameters: see the next section
2023-04-05 11:01:30 +00:00
- `-lg` | `--linear_gradient`: The cross fade length of two audio slices in seconds. If there is a discontinuous voice after forced slicing, you can adjust this value. Otherwise, it is recommended to use the default value of 0.
2023-05-13 13:04:59 +00:00
- `-f0p` | `--f0_predictor`: Select F0 predictor, can select crepe,pm,dio,harvest, default pm(note: crepe is original F0 meaning pooling)
2023-04-05 11:01:30 +00:00
- `-a` | `--auto_predict_f0`: automatic pitch prediction for voice conversion, do not enable this when converting songs as it can cause serious pitch issues.
- `-cm` | `--cluster_model_path`: path to the clustering model, fill in any value if clustering is not trained.
- `-cr` | `--cluster_infer_ratio`: proportion of the clustering solution, range 0-1, fill in 0 if the clustering model is not trained.
2023-04-09 03:36:55 +00:00
- `-eh` | `--enhance`: Whether to use NSF_HIFIGAN enhancer, this option has certain effect on sound quality enhancement for some models with few training sets, but has negative effect on well-trained models, so it is turned off by default.
2023-03-11 05:23:24 +00:00
2023-03-20 11:07:59 +00:00
## 🤔 Optional Settings
2023-03-11 05:23:24 +00:00
If the results from the previous section are satisfactory, or if you didn't understand what is being discussed in the following section, you can skip it, and it won't affect the model usage. (These optional settings have a relatively small impact, and they may have some effect on certain specific data, but in most cases, the difference may not be noticeable.)
### Automatic f0 prediction
During the 4.0 model training, an f0 predictor is also trained, which can be used for automatic pitch prediction during voice conversion. However, if the effect is not good, manual pitch prediction can be used instead. But please do not enable this feature when converting singing voice as it may cause serious pitch shifting!
2023-04-04 14:44:55 +00:00
- Set `auto_predict_f0` to true in inference_main.
2023-03-11 05:23:24 +00:00
### Cluster-based timbre leakage control
Introduction: The clustering scheme can reduce timbre leakage and make the trained model sound more like the target's timbre (although this effect is not very obvious), but using clustering alone will lower the model's clarity (the model may sound unclear). Therefore, this model adopts a fusion method to linearly control the proportion of clustering and non-clustering schemes. In other words, you can manually adjust the ratio between "sounding like the target's timbre" and "being clear and articulate" to find a suitable trade-off point.
The existing steps before clustering do not need to be changed. All you need to do is to train an additional clustering model, which has a relatively low training cost.
- Training process:
2023-04-09 03:36:55 +00:00
- Train on a machine with good CPU performance. According to my experience, it takes about 4 minutes to train each speaker on a Tencent Cloud machine with 6-core CPU.
- Execute `python cluster/train_cluster.py`. The output model will be saved in `logs/44k/kmeans_10000.pt`.
2023-03-11 05:23:24 +00:00
- Inference process:
2023-04-09 03:36:55 +00:00
- Specify `cluster_model_path` in `inference_main.py`.
- Specify `cluster_infer_ratio` in `inference_main.py`, where `0` means not using clustering at all, `1` means only using clustering, and usually `0.5` is sufficient.
2023-03-11 05:23:24 +00:00
2023-04-30 03:33:03 +00:00
### [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/svc-develop-team/so-vits-svc/blob/4.0-Vec768-Layer12/sovits4_for_colab.ipynb) [sovits4_for_colab.ipynb](https://colab.research.google.com/github/svc-develop-team/so-vits-svc/blob/4.0-Vec768-Layer12/sovits4_for_colab.ipynb)
2023-04-14 05:55:09 +00:00
**[23/03/16] No longer need to download hubert manually**
**[23/04/14] Support NSF_HIFIGAN enhancer**
2023-03-12 03:24:13 +00:00
2023-03-20 11:07:59 +00:00
## 📤 Exporting to Onnx
2023-03-11 05:23:24 +00:00
Use [onnx_export.py](https://github.com/svc-develop-team/so-vits-svc/blob/4.0/onnx_export.py)
2023-03-16 14:57:05 +00:00
- Create a folder named `checkpoints` and open it
- Create a folder in the `checkpoints` folder as your project folder, naming it after your project, for example `aziplayer`
- Rename your model as `model.pth`, the configuration file as `config.json`, and place them in the `aziplayer` folder you just created
- Modify `"NyaruTaffy"` in `path = "NyaruTaffy"` in [onnx_export.py](https://github.com/svc-develop-team/so-vits-svc/blob/4.0/onnx_export.py) to your project name, `path = "aziplayer"`
- Run [onnx_export.py](https://github.com/svc-develop-team/so-vits-svc/blob/4.0/onnx_export.py)
2023-03-11 05:23:24 +00:00
- Wait for it to finish running. A `model.onnx` will be generated in your project folder, which is the exported model.
### UI support for Onnx models
- [MoeSS](https://github.com/NaruseMioShirakana/MoeSS)
2023-04-09 03:36:55 +00:00
- [Hubert4.0](https://huggingface.co/NaruseMioShirakana/MoeSS-SUBModel)
Note: For Hubert Onnx models, please use the models provided by MoeSS. Currently, they cannot be exported on their own (Hubert in fairseq has many unsupported operators and things involving constants that can cause errors or result in problems with the input/output shape and results when exported.)
2023-03-11 05:23:24 +00:00
2023-04-09 03:36:55 +00:00
CppDataProcess are some functions to preprocess data used in MoeSS
2023-03-11 05:23:24 +00:00
2023-03-24 08:59:47 +00:00
## ☀️ Previous contributors
2023-03-22 13:04:52 +00:00
For some reason the author deleted the original repository. Because of the negligence of the organization members, the contributor list was cleared because all files were directly reuploaded to this repository at the beginning of the reconstruction of this repository. Now add a previous contributor list to README.md.
*Some members have not listed according to their personal wishes.*
<table>
<tr>
<td align="center"><a href="https://github.com/MistEO"><img src="https://avatars.githubusercontent.com/u/18511905?v=4" width="100px;" alt=""/><br /><sub><b>MistEO</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/XiaoMiku01"><img src="https://avatars.githubusercontent.com/u/54094119?v=4" width="100px;" alt=""/><br /><sub><b>XiaoMiku01</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/ForsakenRei"><img src="https://avatars.githubusercontent.com/u/23041178?v=4" width="100px;" alt=""/><br /><sub><b>しぐれ</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/TomoGaSukunai"><img src="https://avatars.githubusercontent.com/u/25863522?v=4" width="100px;" alt=""/><br /><sub><b>TomoGaSukunai</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/Plachtaa"><img src="https://avatars.githubusercontent.com/u/112609742?v=4" width="100px;" alt=""/><br /><sub><b>Plachtaa</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/zdxiaoda"><img src="https://avatars.githubusercontent.com/u/45501959?v=4" width="100px;" alt=""/><br /><sub><b>zd小达</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/Archivoice"><img src="https://avatars.githubusercontent.com/u/107520869?v=4" width="100px;" alt=""/><br /><sub><b>凍聲響世</b></sub></a><br /></td>
</tr>
</table>
2023-03-20 11:07:59 +00:00
## 📚 Some legal provisions for reference
2023-03-11 05:23:24 +00:00
2023-03-22 12:47:48 +00:00
#### Any country, region, organization, or individual using this project must comply with the following laws.
2023-03-11 05:23:24 +00:00
#### 《民法典》
##### 第一千零一十九条
2023-04-04 14:44:55 +00:00
任何组织或者个人不得以丑化、污损,或者利用信息技术手段伪造等方式侵害他人的肖像权。未经肖像权人同意,不得制作、使用、公开肖像权人的肖像,但是法律另有规定的除外。未经肖像权人同意,肖像作品权利人不得以发表、复制、发行、出租、展览等方式使用或者公开肖像权人的肖像。对自然人声音的保护,参照适用肖像权保护的有关规定。
2023-03-11 05:23:24 +00:00
##### 第一千零二十四条
2023-03-12 02:46:22 +00:00
【名誉权】民事主体享有名誉权。任何组织或者个人不得以侮辱、诽谤等方式侵害他人的名誉权。
2023-03-11 05:23:24 +00:00
##### 第一千零二十七条
2023-04-04 14:44:55 +00:00
【作品侵害名誉权】行为人发表的文学、艺术作品以真人真事或者特定人为描述对象,含有侮辱、诽谤内容,侵害他人名誉权的,受害人有权依法请求该行为人承担民事责任。行为人发表的文学、艺术作品不以特定人为描述对象,仅其中的情节与该特定人的情况相似的,不承担民事责任。
2023-03-22 12:47:48 +00:00
#### 《[中华人民共和国宪法](http://www.gov.cn/guoqing/2018-03/22/content_5276318.htm)》
#### 《[中华人民共和国刑法](http://gongbao.court.gov.cn/Details/f8e30d0689b23f57bfc782d21035c3.html?sw=%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91%E5%85%B1%E5%92%8C%E5%9B%BD%E5%88%91%E6%B3%95)》
2023-03-22 13:04:52 +00:00
#### 《[中华人民共和国民法典](http://gongbao.court.gov.cn/Details/51eb6750b8361f79be8f90d09bc202.html)》
2023-03-24 12:22:52 +00:00
## 💪 Thanks to all contributors for their efforts
2023-03-24 12:25:15 +00:00
<a href="https://github.com/svc-develop-team/so-vits-svc/graphs/contributors" target="_blank">
<img src="https://contrib.rocks/image?repo=svc-develop-team/so-vits-svc" />
</a>