This commit is contained in:
litagin02
2023-12-27 16:58:58 +09:00
parent 5be778284b
commit 33c6f175e5
6 changed files with 56 additions and 26 deletions

View File

@@ -63,6 +63,9 @@ model_assets
- この手順は、音声ファイルたちからスタイルを作るのに必要な手順です。
- 学習とは独立しているので、学習中でもできるし、学習が終わっても何度もやりなおせます。
### データセット作り
- `Dataset.bat`をダブルクリックすると、音声ファイルからデータセットを作るためのWebUIが起動します。音声ファイルのみからでもこれを使って学習できます。
## Bert-VITS2 v2.1と違う点
- 感情埋め込みのモデルを変更([wav2vec2-large-robust-12-ft-emotion-msp-dim](https://huggingface.co/audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim)から[wespeaker-voxceleb-resnet34-LM](https://huggingface.co/pyannote/wespeaker-voxceleb-resnet34-LM)へ、感情埋め込みというより正確には話者埋め込みが近い)
@@ -77,7 +80,6 @@ model_assets
- [ ] 複数話者学習での音声合成対応(学習は現在でも可能)
- [ ] 本家のver 2.1, 2.2, 2.3モデルの推論対応ver 2.1以外は明らかにめんどいのでたぶんやらない)
- [ ] `server_fastapi.py`の対応、とくにAPIで使えるようになると嬉しい人が増えるのかもしれない
- [ ] 音声ファイルだけ与えられた時にスライスしたり書き起こしたりしてデータセットを作れてすぐ学習できる機能をつける?[このライブラリ](https://github.com/litagin02/slice-and-transcribe)を組み込む?
## Bert-VITS2 v2.1と同じ点
- [事前学習モデル](https://huggingface.co/litagin/style_bert_vits2_jvnv)は、実質Bert-VITS2 v2.1と同じものを使用しています不要な重みを削ってsafetensorsに変換したもの

View File

@@ -15,7 +15,7 @@
"## そもそもスタイルベクトルとは\n",
"[この話者識別モデル](https://huggingface.co/pyannote/wespeaker-voxceleb-resnet34-LM)を使って生成された、1つの音声ファイルにつき256次元のベクトルです。話者識別用のものですが、感情や声音の特徴も含まれているので、スタイルベクトルとして使えます。\n",
"\n",
"このStyle Bert-VITS2では、この256次元のベクトルをエンコーダに注入して学習しているので、推論時にそのベクトルを入れてあげる必要があります。ある感情を強く表していると思われるベクトルを入れると、その感情を強く表現した音声が生成される、という仕組みです。\n",
"このStyle-Bert-VITS2では、この256次元のベクトルをエンコーダに注入して学習しているので、推論時にそのベクトルを入れてあげる必要があります。ある感情を強く表していると思われるベクトルを入れると、その感情を強く表現した音声が生成される、という仕組みです。\n",
"\n",
"もともとが話者識別用なので、「この感情はこのベクトル」のような普遍的なスタイルベクトルは使えません。なのでこのように、いちいちデータセットごとにベクトルを作る必要があります。\n",
"\n",

View File

@@ -1,7 +1,13 @@
chcp 65001 > NUL
@REM ↑文字コードのおまじないらしい
@REM https://github.com/Zuntan03/EasyBertVits2 より引用・改変
@REM 2. Style-Bert-VITS2.zip を解凍名前がBert-VITS2-masterになる
@REM 3. Style-Bert-VITS2-master を Style-Bert-VITS2 にリネーム
@echo off
pushd %~dp0
set PS_CMD=PowerShell -Version 5.1 -ExecutionPolicy Bypass
@@ -12,33 +18,47 @@ if not exist %CURL_CMD% (
pause & popd & exit /b 1
)
@REM lib フォルダがなければ作成
if not exist lib\ ( mkdir lib )
@REM Style-Bert-VITS2.zip をGitHubのmasterの最新のものをダウンロード
%CURL_CMD% -Lo Style-Bert-VITS2.zip^
https://github.com/litagin02/Style-Bert-VITS2/archive/refs/heads/master.zip
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
@REM Style-Bert-VITS2.zip を解凍フォルダ名前がBert-VITS2-masterになる
%PS_CMD% Expand-Archive -Path Style-Bert-VITS2.zip -DestinationPath . -Force
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
@REM 元のzipを削除しStyle-Bert-VITS2-master を Style-Bert-VITS2 にリネーム
del Style-Bert-VITS2.zip
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
ren Style-Bert-VITS2-master Style-Bert-VITS2
@REM Pythonと仮想環境のセットアップを呼び出す仮想環境が有効化されて戻ってくる
call Style-Bert-VITS2\scripts\Setup-Python.bat ..\..\lib\python ..\venv
if %errorlevel% neq 0 ( popd & exit /b %errorlevel% )
@REM 依存関係インストール
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
pip install -r Style-Bert-VITS2\requirements.txt
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
@REM Style-Bert-VITS2フォルダに移動
pushd Style-Bert-VITS2
python initialize.py
popd
popd
@REM 初期化(必要なモデルのダウンロード)
python initialize.py
@REM 音声合成WebUIの起動
python app.py
pause
popd
popd

View File

@@ -1,5 +1,5 @@
"""
Original `webui.py` for Bert-VITS2, not working with Style Bert-VITS2 yet.
Original `webui.py` for Bert-VITS2, not working with Style-Bert-VITS2 yet.
"""
# flake8: noqa: E402
import os

View File

@@ -69,6 +69,7 @@ Style-Bert-VITS2の学習用データセットを作成するためのツール
細かいパラメータ調整とかがしたい人は、`slice.py`と`transcribe.py`を眺めて直接実行してください。
また、出来上がった音声ファイルたちは`Data/{モデル名}/raw`に、書き起こしファイルは`Data/{モデル名}/esd.list`に保存されます。
書き起こしの結果は、**そこまで正確に誤字や誤りを修正しなくても、それなりの質になる**ので、あまり修正は必要ないかもしれません(私は手動修正したことないです)。
**ffmpeg のインストールが別途必要のよう**です、「Couldn't find ffmpeg」とか怒られたら、「Windows ffmpeg インストール」等でググって別途インストールしてください。
"""
@@ -80,7 +81,7 @@ with gr.Blocks(theme="NoCrypt/miku") as app:
slice_button = gr.Button("音声のスライス")
result1 = gr.Textbox(label="結果")
with gr.Row():
transcribe_button = gr.Button("2. 音声の文字起こし")
transcribe_button = gr.Button("音声の文字起こし")
result2 = gr.Textbox(label="結果")
slice_button.click(
do_slice,

View File

@@ -29,7 +29,7 @@ def get_path(model_name):
return dataset_path, lbl_path, train_path, val_path, config_path
def initialize(model_name, batch_size, epochs):
def initialize(model_name, batch_size, epochs, bf16_run):
dataset_path, _, train_path, val_path, config_path = get_path(model_name)
if os.path.isfile(config_path):
config = json.load(open(config_path, "r", encoding="utf-8"))
@@ -41,6 +41,7 @@ def initialize(model_name, batch_size, epochs):
config["data"]["validation_files"] = val_path
config["train"]["batch_size"] = batch_size
config["train"]["epochs"] = epochs
config["train"]["bf16_run"] = bf16_run
model_path = os.path.join(dataset_path, "models")
try:
@@ -198,7 +199,6 @@ if __name__ == "__main__":
with gr.Row():
with gr.Column():
gr.Markdown(value="### Step 1: 設定ファイルの生成")
with gr.Row():
batch_size = gr.Slider(
label="バッチサイズ",
info="VRAM 12GBで4くらい",
@@ -215,6 +215,11 @@ if __name__ == "__main__":
maximum=1000,
step=1,
)
bf16_run = gr.Checkbox(
label="bfloat16を使う",
info="新しめのグラボだと学習が早くなるかも、古いグラボだと動かないかも",
value=True,
)
generate_config_btn = gr.Button(value="実行", variant="primary")
with gr.Column():
gr.Markdown(value="### Step 2: 音声ファイルの前処理")
@@ -234,7 +239,9 @@ if __name__ == "__main__":
train_btn = gr.Button(value="学習", variant="primary")
generate_config_btn.click(
initialize, inputs=[model_name, batch_size, epochs], outputs=[info]
initialize,
inputs=[model_name, batch_size, epochs, bf16_run],
outputs=[info],
)
resample_btn.click(resample, inputs=[model_name], outputs=[info])
preprocess_text_btn.click(preprocess_text, inputs=[model_name], outputs=[info])