This commit is contained in:
litagin02
2024-06-01 20:08:31 +09:00
parent a271b8a41c
commit 31b709eef6
5 changed files with 26 additions and 147 deletions

View File

@@ -9,14 +9,13 @@ https://github.com/litagin02/Style-Bert-VITS2/assets/139731664/e853f9a2-db4a-420
You can install via `pip install style-bert-vits2` (inference only), see [library.ipynb](/library.ipynb) for example usage.
- **解説チュートリアル動画** [YouTube](https://youtu.be/aTUSzgDl1iY) [ニコニコ動画](https://www.nicovideo.jp/watch/sm43391524)
- [English README](docs/README_en.md)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
- [FAQ](/docs/FAQ.md)
- [🤗 オンラインデモはこちらから](https://huggingface.co/spaces/litagin/Style-Bert-VITS2-Editor-Demo)
- [Zennの解説記事](https://zenn.dev/litagin/articles/034819a5256ff4)
- [**リリースページ**](https://github.com/litagin02/Style-Bert-VITS2/releases/)、[更新履歴](/docs/CHANGELOG.md)
- 2024-05-26: Ver 2.5.0 (**[利用規約](/docs/TERMS_OF_USE.md)の追加**、フォルダ分けからのスタイル生成、小春音アミ・あみたろモデルの追加)
- 2024-06-01: Ver 2.5.0 (**[利用規約](/docs/TERMS_OF_USE.md)の追加**、フォルダ分けからのスタイル生成、小春音アミ・あみたろモデルの追加、インストールの高速化等)
- 2024-03-16: ver 2.4.1 (**batファイルによるインストール方法の変更**)
- 2024-03-15: ver 2.4.0 (大規模リファクタリングや種々の改良、ライブラリ化)
- 2024-02-26: ver 2.3 (辞書機能とエディター機能)
@@ -35,13 +34,15 @@ This repository is based on [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2
- 入力されたテキストの内容をもとに感情豊かな音声を生成する[Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)のv2.1とJapanese-Extraを元に、感情や発話スタイルを強弱込みで自由に制御できるようにしたものです。
- GitやPythonがない人でもWindowsユーザーなら簡単にインストールでき、学習もできます (多くを[EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2/)からお借りしました)。またGoogle Colabでの学習もサポートしています: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
- 音声合成のみに使う場合は、グラボがなくてもCPUで動作します。
- 音声合成のみに使う場合、Pythonライブラリとして`pip install style-bert-vits2`でインストールできます。例は[library.ipynb](/library.ipynb)を参照してください。
- 他との連携に使えるAPIサーバーも同梱しています ([@darai0512](https://github.com/darai0512) 様によるPRです、ありがとうございます)。
- 元々「楽しそうな文章は楽しそうに、悲しそうな文章は悲しそうに」読むのがBert-VITS2の強みですので、スタイル指定がデフォルトでも感情豊かな音声を生成することができます。
## 使い方
CLIでの使い方は[こちら](/docs/CLI.md)を参照してください。
- CLIでの使い方は[こちら](/docs/CLI.md)を参照してください。
- [よくある質問](/docs/FAQ.md)も参照してください。
### 動作環境
@@ -55,7 +56,7 @@ Pythonライブラリとしてのpipでのインストールや使用例は[libr
Windowsを前提としています。
1. [このzipファイル](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.4.1/sbv2.zip)を**パスに日本語や空白が含まれない場所に**ダウンロードして展開します。
1. [このzipファイル](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.5.0/sbv2.zip)を**パスに日本語や空白が含まれない場所に**ダウンロードして展開します。
- グラボがある方は、`Install-Style-Bert-VITS2.bat`をダブルクリックします。
- グラボがない方は、`Install-Style-Bert-VITS2-CPU.bat`をダブルクリックします。CPU版では学習はできませんが、音声合成とマージは可能です。
2. 待つと自動で必要な環境がインストールされます。
@@ -67,13 +68,17 @@ Windowsを前提としています。
#### GitやPython使える人
Pythonの仮想環境・パッケージ管理ツールである[uv](https://github.com/astral-sh/uv)がpipより高速なので、それを使ってインストールすることをお勧めします。
使いたくない場合は通常のpipでも大丈夫です。
```bash
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
git clone https://github.com/litagin02/Style-Bert-VITS2.git
cd Style-Bert-VITS2
python -m venv venv
uv venv venv
uv pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118
uv pip install -r requirements.txt
venv\Scripts\activate
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
python initialize.py # 必要なモデルとデフォルトTTSモデルをダウンロード
```
最後を忘れずに。
@@ -119,10 +124,6 @@ model_assets
- `App.bat`をダブルクリックか`python app.py`したところの「データセット作成」タブから、音声ファイルを適切な長さにスライスし、その後に文字の書き起こしを自動で行えます。
- 指示に従った後、下の「学習」タブでそのまま学習を行うことができます。
注意: データセットの手動修正やノイズ除去等、細かい修正を行いたい場合は[Aivis](https://github.com/tsukumijima/Aivis)や、そのデータセット部分のWindows対応版 [Aivis Dataset](https://github.com/litagin02/Aivis-Dataset) を使うといいかもしれません。ですがファイル数が多い場合などは、このツールで簡易的に切り出してデータセットを作るだけでも十分という気もしています。
データセットがどのようなものがいいかは各自試行錯誤中してください。
#### 学習WebUI
- `App.bat`をダブルクリックか`python app.py`して開くWebUIの「学習」タブから指示に従ってください。
@@ -130,7 +131,7 @@ model_assets
### スタイルの生成
- デフォルトでは、デフォルトスタイル「Neutral」の他、学習フォルダのフォルダ分けに応じたスタイルが生成されます。
- それ以外の方法でスタイルを成したい人向けです。
- それ以外の方法で手動でスタイルを成したい人向けです。
- `App.bat`をダブルクリックか`python app.py`して開くWebUIの「スタイル作成」タブから、音声ファイルを使ってスタイルを生成できます。
- 学習とは独立しているので、学習中でもできるし、学習が終わっても何度もやりなおせます(前処理は終わらせている必要があります)。

View File

@@ -45,12 +45,16 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"PATH\"] += \":/root/.cargo/bin\"\n",
"\n",
"!curl -LsSf https://astral.sh/uv/install.sh | sh\n",
"!git clone https://github.com/litagin02/Style-Bert-VITS2.git\n",
"%cd Style-Bert-VITS2/\n",
"# 後で消す!!!\n",
"!git checkout dev\n",
"# 後で消す!!!\n",
"!pip install uv\n",
"!uv pip install --system -q -r requirements-colab.txt\n",
"!python initialize.py --skip_default_models"
]

View File

@@ -7,17 +7,17 @@ git clone https://github.com/litagin02/Style-Bert-VITS2.git
cd Style-Bert-VITS2
python -m venv venv
venv\Scripts\activate
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
```
Then download the necessary models and the default TTS model, and set the global paths.
```bash
python initialize.py [--skip_jvnv] [--dataset_root <path>] [--assets_root <path>]
python initialize.py [--skip_default_models] [--dataset_root <path>] [--assets_root <path>]
```
Optional:
- `--skip_jvnv`: Skip downloading the default JVNV voice models (use this if you only have to train your own models).
- `--skip_default_models`: Skip downloading the default voice models (use this if you only have to train your own models).
- `--dataset_root`: Default: `Data`. Root directory of the training dataset. The training dataset of `{model_name}` should be placed in `{dataset_root}/{model_name}`.
- `--assets_root`: Default: `model_assets`. Root directory of the model assets (for inference). In training, the model assets will be saved to `{assets_root}/{model_name}`, and in inference, we load all the models from `{assets_root}`.
@@ -26,7 +26,7 @@ Optional:
### 1.1. Slice audio files
The following audio formats are supported: ".wav", ".flac", ".mp3", ".ogg", ".opus".
The following audio formats are supported: ".wav", ".flac", ".mp3", ".ogg", ".opus", ".m4a".
```bash
python slice.py --model_name <model_name> [-i <input_dir>] [-m <min_sec>] [-M <max_sec>] [--time_suffix]
```
@@ -101,4 +101,4 @@ python train_ms_jp_extra.py [--repo_id <username>/<repo_name>] [--skip_default_s
Optional:
- `--repo_id`: Hugging Face repository ID to upload the trained model to. You should have logged in using `huggingface-cli login` before running this command.
- `--skip_default_style`: Skip making the default style vector. Use this if you want to resume training (since the default style vector is already made).
- `--skip_default_style`: Skip making the default style vector. Use this if you want to resume training (since the default style vector has been already made).

View File

@@ -1,127 +0,0 @@
# This English README is for 1.x versions. WIP for 2.x versions.
# Style-Bert-VITS2
Bert-VITS2 with more controllable voice styles.
https://github.com/litagin02/Style-Bert-VITS2/assets/139731664/b907c1b8-43aa-46e6-b03f-f6362f5a5a1e
[Zenn Commentary Article (translated)](Style-Bert-VITS2_en.md) ([original](https://zenn.dev/litagin/articles/034819a5256ff4))
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
Online demo: https://huggingface.co/spaces/litagin/Style-Bert-VITS2-JVNV
This repository is based on [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2) v2.1, so many thanks to the original author!
- [Update History](docs/CHANGELOG.md)
**Overview**
- Based on Bert-VITS2 v2.1, which generates emotionally rich voices from entered text, this version allows free control of emotions and speaking styles, including intensity.
- Easy to install and train for people without Git or Python (for Windows users), much is borrowed from [EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2/). Training on Google Colab is also supported: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
- If used only for voice synthesis, it can operate on CPU without a graphics card.
- Also includes an API server for integration with others (PR by [@darai0512](https://github.com/darai0512), thank you).
- Originally, Bert-VITS2's strength was to read "happy text happily, sad text sadly", so even without using the added style specification in this fork, you can generate emotionally rich voices.
## How to Use
<!-- For more details, please refer to [here](docs/tutorial.md). -->
### Operating Environment
We have confirmed the operation in Windows Command Prompt, WSL2, and Linux (Ubuntu Desktop) for each UI and API Server (please be creative with path specifications in WSL).
### Installation
#### For Those Unfamiliar with Git or Python
Assuming Windows:
1. Download and unzip [this zip file](https://github.com/litagin02/Style-Bert-VITS2/releases/download/1.3/Style-Bert-VITS2.zip).
- If you have a graphics card, double-click `Install-Style-Bert-VITS2.bat`.
- If you don't have a graphics card, double-click `Install-Style-Bert-VITS2-CPU.bat`.
2. Wait for the necessary environment to install automatically.
3. After that, if the WebUI for voice synthesis launches automatically, the installation is successful. The default model will be downloaded, so you can play with it immediately.
For updates, please double-click `Update-Style-Bert-VITS2.bat`.
#### For Those Familiar with Git and Python
```bash
git clone https://github.com/litagin02/Style-Bert-VITS2.git
cd Style-Bert-VITS2
python -m venv venv
venv\Scripts\activate
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
python initialize.py # Download necessary models and default TTS model
```
Don't forget the last step.
### Voice Synthesis
Double-click `App.bat` or run `python app.py` to launch the WebUI. The default model is downloaded during installation, so you can use it even if you haven't trained it.
The structure of the model files required for voice synthesis is as follows (you don't need to place them manually):
```
model_assets
├── your_model
│ ├── config.json
│ ├── your_model_file1.safetensors
│ ├── your_model_file2.safetensors
│ ├── ...
│ └── style_vectors.npy
└── another_model
├── ...
```
For inference, `config.json`, `*.safetensors`, and `style_vectors.npy` are necessary. If you want to share a model, please share these three files.
Among them, `style_vectors.npy` is a file necessary to control the style. By default, the average style "Neutral" is generated during training.
If you want to use multiple styles for more detailed control, please refer to "Generating Styles" below (even with only the average style, if the training data is emotionally rich, sufficiently emotionally rich voices can be generated).
### Training
Double-click Train.bat or run `python webui_train.py` to launch the WebUI.
### Generating Styles
For those who want to use styles other than the default "Neutral".
- Double-click `Style.bat` or run `python webui_style_vectors.py` to launch the WebUI.
- It is independent of training, so you can do it even during training, and you can redo it any number of times after training is complete (preprocessing must be finished).
- For more details on the specifications of the style, please refer to [clustering.ipynb](../clustering.ipynb).
### Dataset Creation
- Double-click `Dataset.bat` or run `python webui_dataset.py` to launch the WebUI for creating datasets from audio files. You can use this tool to learn from audio files only.
Note: If you want to manually correct the dataset, remove noise, etc., you may find [Aivis](https://github.com/tsukumijima/Aivis) or its Windows-compatible dataset part [Aivis Dataset](https://github.com/litagin02/Aivis-Dataset) useful. However, if there are many files, etc., it may be sufficient to simply cut out and create a dataset with this tool.
Please experiment to see what kind of dataset is best.
### API Server
Run `python server_fastapi.py` in the constructed environment to launch the API server.
Please check the API specification after launching at `/docs`.
By default, CORS settings are allowed for all domains.
As much as possible, change the value of server.origins in `config.yml` and limit it to trusted domains (if you delete the key, you can disable the CORS settings).
### Merging
You can create a new model by mixing two models in terms of "voice", "emotional expression", and "tempo".
Double-click `Merge.bat` or run `python webui_merge.py` to launch the WebUI.
## Relation to Bert-VITS2 v2.1
Basically, it's just a slight modification of the Bert-VITS2 v2.1 model structure. The [pre-trained model](https://huggingface.co/litagin/Style-Bert-VITS2-1.0-base) is also essentially the same as Bert-VITS2 v2.1 (unnecessary weights have been removed and converted to safetensors).
The differences are as follows:
- Like [EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2), it is easy to use even for people who do not know Python or Git.
- Changed the model for emotional embedding (from 1024-dimensional [wav2vec2-large-robust-12-ft-emotion-msp-dim](https://huggingface.co/audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim) to 256-dimensional [wespeaker-voxceleb-resnet34-LM](https://huggingface.co/pyannote/wespeaker-voxceleb-resnet34-LM), which is more for speaker identification than emotional embedding)
- Removed vector quantization from embeddings and replaced it with just a fully connected layer.
- By creating a style vector file `style_vectors.npy`, you can generate voices using that style and continuously specify the strength of the effect.
- Various WebUIs created
- Support for bf16 training
- Support for safetensors format, defaulting to using safetensors
- Other minor bug fixes and refactoring

View File

@@ -126,7 +126,8 @@
"name": "python3"
},
"language_info": {
"name": "python"
"name": "python",
"version": "3.10.11"
}
},
"nbformat": 4,