Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .dockerignore +17 -0
- .gitattributes +2 -35
- .gitignore +39 -0
- .vscode/extensions.json +6 -0
- .vscode/settings.json +26 -0
- App.bat +11 -0
- Data/.gitignore +2 -0
- Dockerfile.deploy +23 -0
- Dockerfile.train +109 -0
- Editor.bat +11 -0
- LGPL_LICENSE +165 -0
- LICENSE +661 -0
- README.md +241 -8
- Server.bat +11 -0
- app.py +65 -0
- bert/bert_models.json +14 -0
- bert/chinese-roberta-wwm-ext-large/.gitattributes +9 -0
- bert/chinese-roberta-wwm-ext-large/README.md +57 -0
- bert/chinese-roberta-wwm-ext-large/added_tokens.json +1 -0
- bert/chinese-roberta-wwm-ext-large/config.json +28 -0
- bert/chinese-roberta-wwm-ext-large/special_tokens_map.json +1 -0
- bert/chinese-roberta-wwm-ext-large/tokenizer.json +0 -0
- bert/chinese-roberta-wwm-ext-large/tokenizer_config.json +1 -0
- bert/chinese-roberta-wwm-ext-large/vocab.txt +0 -0
- bert/deberta-v2-large-japanese-char-wwm/.gitattributes +34 -0
- bert/deberta-v2-large-japanese-char-wwm/README.md +89 -0
- bert/deberta-v2-large-japanese-char-wwm/config.json +37 -0
- bert/deberta-v2-large-japanese-char-wwm/special_tokens_map.json +7 -0
- bert/deberta-v2-large-japanese-char-wwm/tokenizer_config.json +19 -0
- bert/deberta-v2-large-japanese-char-wwm/vocab.txt +0 -0
- bert/deberta-v3-large/.gitattributes +27 -0
- bert/deberta-v3-large/README.md +93 -0
- bert/deberta-v3-large/config.json +22 -0
- bert/deberta-v3-large/generator_config.json +22 -0
- bert/deberta-v3-large/tokenizer_config.json +4 -0
- bert_gen.py +99 -0
- clustering.ipynb +0 -0
- colab.ipynb +384 -0
- config.py +292 -0
- configs/config.json +73 -0
- configs/config_jp_extra.json +80 -0
- configs/paths.yml +2 -0
- data_utils.py +458 -0
- default_config.yml +70 -0
- default_style.py +34 -0
- dict_data/.gitignore +3 -0
- docs/CHANGELOG.md +275 -0
- docs/CLI.md +104 -0
- docs/README_en.md +127 -0
- docs/Style-Bert-VITS2_en.md +207 -0
.dockerignore
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Dockerfile.deploy用の.dockerignore
|
2 |
+
# 日本語のJP-Extraのエディター稼働のみに必要なファイルを指定する
|
3 |
+
|
4 |
+
*
|
5 |
+
|
6 |
+
!/style_bert_vits2/
|
7 |
+
|
8 |
+
!/bert/deberta-v2-large-japanese-char-wwm/
|
9 |
+
!/common/
|
10 |
+
!/configs/
|
11 |
+
!/dict_data/default.csv
|
12 |
+
!/model_assets/
|
13 |
+
|
14 |
+
!/config.py
|
15 |
+
!/default_config.yml
|
16 |
+
!/requirements.txt
|
17 |
+
!/server_editor.py
|
.gitattributes
CHANGED
@@ -1,35 +1,2 @@
|
|
1 |
-
*.
|
2 |
-
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
*.bat text eol=crlf
|
2 |
+
style_bert_vits2/nlp/english/cmudict_cache.pickle filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__/
|
2 |
+
venv/
|
3 |
+
.venv/
|
4 |
+
dist/
|
5 |
+
.coverage
|
6 |
+
.ipynb_checkpoints/
|
7 |
+
.ruff_cache/
|
8 |
+
|
9 |
+
/*.yml
|
10 |
+
!/default_config.yml
|
11 |
+
/bert/*/*.bin
|
12 |
+
/bert/*/*.h5
|
13 |
+
/bert/*/*.model
|
14 |
+
/bert/*/*.safetensors
|
15 |
+
/bert/*/*.msgpack
|
16 |
+
|
17 |
+
/pretrained/*.safetensors
|
18 |
+
/pretrained/*.pth
|
19 |
+
|
20 |
+
/pretrained_jp_extra/*.safetensors
|
21 |
+
/pretrained_jp_extra/*.pth
|
22 |
+
|
23 |
+
/slm/*/*.bin
|
24 |
+
|
25 |
+
/scripts/test/
|
26 |
+
/scripts/lib/
|
27 |
+
/scripts/Style-Bert-VITS2/
|
28 |
+
/scripts/sbv2/
|
29 |
+
*.zip
|
30 |
+
*.csv
|
31 |
+
*.bak
|
32 |
+
/mos_results/
|
33 |
+
|
34 |
+
safetensors.ipynb
|
35 |
+
*.wav
|
36 |
+
/static/
|
37 |
+
|
38 |
+
# pyopenjtalk's dictionary
|
39 |
+
*.dic
|
.vscode/extensions.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"recommendations": [
|
3 |
+
"ms-python.python",
|
4 |
+
"ms-python.vscode-pylance"
|
5 |
+
]
|
6 |
+
}
|
.vscode/settings.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
// Pylance の Type Checking を有効化
|
3 |
+
"python.languageServer": "Pylance",
|
4 |
+
"python.analysis.typeCheckingMode": "strict",
|
5 |
+
// Pylance の Type Checking のうち、いくつかのエラー報告を抑制する
|
6 |
+
"python.analysis.diagnosticSeverityOverrides": {
|
7 |
+
"reportConstantRedefinition": "none",
|
8 |
+
"reportGeneralTypeIssues": "warning",
|
9 |
+
"reportMissingParameterType": "warning",
|
10 |
+
"reportMissingTypeStubs": "none",
|
11 |
+
"reportPrivateImportUsage": "none",
|
12 |
+
"reportPrivateUsage": "warning",
|
13 |
+
"reportShadowedImports": "none",
|
14 |
+
"reportUnnecessaryComparison": "none",
|
15 |
+
"reportUnknownArgumentType": "none",
|
16 |
+
"reportUnknownMemberType": "none",
|
17 |
+
"reportUnknownParameterType": "warning",
|
18 |
+
"reportUnknownVariableType": "none",
|
19 |
+
"reportUnusedFunction": "none",
|
20 |
+
"reportUnusedVariable": "information",
|
21 |
+
},
|
22 |
+
"[python]": {
|
23 |
+
"editor.defaultFormatter": "ms-python.black-formatter",
|
24 |
+
"editor.formatOnType": true,
|
25 |
+
},
|
26 |
+
}
|
App.bat
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
chcp 65001 > NUL
|
2 |
+
@echo off
|
3 |
+
|
4 |
+
pushd %~dp0
|
5 |
+
echo Running app.py...
|
6 |
+
venv\Scripts\python app.py
|
7 |
+
|
8 |
+
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
|
9 |
+
|
10 |
+
popd
|
11 |
+
pause
|
Data/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
*
|
2 |
+
!.gitignore
|
Dockerfile.deploy
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Hugging face spaces (CPU) でエディタ (server_editor.py) のデプロイ用
|
2 |
+
|
3 |
+
# See https://huggingface.co/docs/hub/spaces-sdks-docker-first-demo
|
4 |
+
|
5 |
+
FROM python:3.10
|
6 |
+
|
7 |
+
RUN useradd -m -u 1000 user
|
8 |
+
|
9 |
+
USER user
|
10 |
+
|
11 |
+
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
+
|
14 |
+
WORKDIR $HOME/app
|
15 |
+
|
16 |
+
RUN pip install --no-cache-dir --upgrade pip
|
17 |
+
|
18 |
+
COPY --chown=user . $HOME/app
|
19 |
+
|
20 |
+
RUN pip install --no-cache-dir -r $HOME/app/requirements.txt
|
21 |
+
|
22 |
+
# 必要に応じて制限を変更してください
|
23 |
+
CMD ["python", "server_editor.py", "--line_length", "50", "--line_count", "3"]
|
Dockerfile.train
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# PaperspaceのGradient環境での学習環境構築用Dockerfileです。
|
2 |
+
# 環境のみ構築するため、イメージには学習用のコードは含まれていません。
|
3 |
+
# 以下を参照しました。
|
4 |
+
# https://github.com/gradient-ai/base-container/tree/main/pt211-tf215-cudatk120-py311
|
5 |
+
|
6 |
+
# 主なバージョン等
|
7 |
+
# Ubuntu 22.04
|
8 |
+
# Python 3.10
|
9 |
+
# PyTorch 2.1.2 (CUDA 11.8)
|
10 |
+
# CUDA Toolkit 12.0, CUDNN 8.9.7
|
11 |
+
|
12 |
+
|
13 |
+
# ==================================================================
|
14 |
+
# Initial setup
|
15 |
+
# ------------------------------------------------------------------
|
16 |
+
|
17 |
+
# Ubuntu 22.04 as base image
|
18 |
+
FROM ubuntu:22.04
|
19 |
+
# RUN yes| unminimize
|
20 |
+
|
21 |
+
# Set ENV variables
|
22 |
+
ENV LANG C.UTF-8
|
23 |
+
ENV SHELL=/bin/bash
|
24 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
25 |
+
|
26 |
+
ENV APT_INSTALL="apt-get install -y --no-install-recommends"
|
27 |
+
ENV PIP_INSTALL="python3 -m pip --no-cache-dir install --upgrade"
|
28 |
+
ENV GIT_CLONE="git clone --depth 10"
|
29 |
+
|
30 |
+
# ==================================================================
|
31 |
+
# Tools
|
32 |
+
# ------------------------------------------------------------------
|
33 |
+
|
34 |
+
RUN apt-get update && \
|
35 |
+
$APT_INSTALL \
|
36 |
+
sudo \
|
37 |
+
build-essential \
|
38 |
+
ca-certificates \
|
39 |
+
wget \
|
40 |
+
curl \
|
41 |
+
git \
|
42 |
+
zip \
|
43 |
+
unzip \
|
44 |
+
nano \
|
45 |
+
ffmpeg \
|
46 |
+
software-properties-common \
|
47 |
+
gnupg \
|
48 |
+
python3 \
|
49 |
+
python3-pip \
|
50 |
+
python3-dev
|
51 |
+
|
52 |
+
# ==================================================================
|
53 |
+
# Git-lfs
|
54 |
+
# ------------------------------------------------------------------
|
55 |
+
|
56 |
+
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \
|
57 |
+
$APT_INSTALL git-lfs
|
58 |
+
|
59 |
+
|
60 |
+
# Add symlink so python and python3 commands use same python3.9 executable
|
61 |
+
RUN ln -s /usr/bin/python3 /usr/local/bin/python
|
62 |
+
|
63 |
+
# ==================================================================
|
64 |
+
# Installing CUDA packages (CUDA Toolkit 12.0 and CUDNN 8.9.7)
|
65 |
+
# ------------------------------------------------------------------
|
66 |
+
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin && \
|
67 |
+
mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
|
68 |
+
wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb && \
|
69 |
+
dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb && \
|
70 |
+
cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/ && \
|
71 |
+
apt-get update && \
|
72 |
+
$APT_INSTALL cuda && \
|
73 |
+
rm cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
|
74 |
+
|
75 |
+
# Installing CUDNN
|
76 |
+
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub && \
|
77 |
+
add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" && \
|
78 |
+
apt-get update && \
|
79 |
+
$APT_INSTALL libcudnn8=8.9.7.29-1+cuda12.2 \
|
80 |
+
libcudnn8-dev=8.9.7.29-1+cuda12.2
|
81 |
+
|
82 |
+
|
83 |
+
ENV PATH=$PATH:/usr/local/cuda/bin
|
84 |
+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
|
85 |
+
|
86 |
+
|
87 |
+
# ==================================================================
|
88 |
+
# PyTorch
|
89 |
+
# ------------------------------------------------------------------
|
90 |
+
|
91 |
+
# Based on https://pytorch.org/get-started/locally/
|
92 |
+
|
93 |
+
RUN $PIP_INSTALL torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
94 |
+
|
95 |
+
|
96 |
+
RUN $PIP_INSTALL jupyterlab
|
97 |
+
|
98 |
+
# Install requirements.txt from the project
|
99 |
+
COPY requirements.txt /tmp/requirements.txt
|
100 |
+
RUN $PIP_INSTALL -r /tmp/requirements.txt
|
101 |
+
RUN rm /tmp/requirements.txt
|
102 |
+
|
103 |
+
# ==================================================================
|
104 |
+
# Startup
|
105 |
+
# ------------------------------------------------------------------
|
106 |
+
|
107 |
+
EXPOSE 8888 6006
|
108 |
+
|
109 |
+
CMD jupyter lab --allow-root --ip=0.0.0.0 --no-browser --ServerApp.trust_xheaders=True --ServerApp.disable_check_xsrf=False --ServerApp.allow_remote_access=True --ServerApp.allow_origin='*' --ServerApp.allow_credentials=True
|
Editor.bat
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
chcp 65001 > NUL
|
2 |
+
@echo off
|
3 |
+
|
4 |
+
pushd %~dp0
|
5 |
+
echo Running server_editor.py --inbrowser
|
6 |
+
venv\Scripts\python server_editor.py --inbrowser
|
7 |
+
|
8 |
+
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
|
9 |
+
|
10 |
+
popd
|
11 |
+
pause
|
LGPL_LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
|
9 |
+
This version of the GNU Lesser General Public License incorporates
|
10 |
+
the terms and conditions of version 3 of the GNU General Public
|
11 |
+
License, supplemented by the additional permissions listed below.
|
12 |
+
|
13 |
+
0. Additional Definitions.
|
14 |
+
|
15 |
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16 |
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17 |
+
General Public License.
|
18 |
+
|
19 |
+
"The Library" refers to a covered work governed by this License,
|
20 |
+
other than an Application or a Combined Work as defined below.
|
21 |
+
|
22 |
+
An "Application" is any work that makes use of an interface provided
|
23 |
+
by the Library, but which is not otherwise based on the Library.
|
24 |
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25 |
+
of using an interface provided by the Library.
|
26 |
+
|
27 |
+
A "Combined Work" is a work produced by combining or linking an
|
28 |
+
Application with the Library. The particular version of the Library
|
29 |
+
with which the Combined Work was made is also called the "Linked
|
30 |
+
Version".
|
31 |
+
|
32 |
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33 |
+
Corresponding Source for the Combined Work, excluding any source code
|
34 |
+
for portions of the Combined Work that, considered in isolation, are
|
35 |
+
based on the Application, and not on the Linked Version.
|
36 |
+
|
37 |
+
The "Corresponding Application Code" for a Combined Work means the
|
38 |
+
object code and/or source code for the Application, including any data
|
39 |
+
and utility programs needed for reproducing the Combined Work from the
|
40 |
+
Application, but excluding the System Libraries of the Combined Work.
|
41 |
+
|
42 |
+
1. Exception to Section 3 of the GNU GPL.
|
43 |
+
|
44 |
+
You may convey a covered work under sections 3 and 4 of this License
|
45 |
+
without being bound by section 3 of the GNU GPL.
|
46 |
+
|
47 |
+
2. Conveying Modified Versions.
|
48 |
+
|
49 |
+
If you modify a copy of the Library, and, in your modifications, a
|
50 |
+
facility refers to a function or data to be supplied by an Application
|
51 |
+
that uses the facility (other than as an argument passed when the
|
52 |
+
facility is invoked), then you may convey a copy of the modified
|
53 |
+
version:
|
54 |
+
|
55 |
+
a) under this License, provided that you make a good faith effort to
|
56 |
+
ensure that, in the event an Application does not supply the
|
57 |
+
function or data, the facility still operates, and performs
|
58 |
+
whatever part of its purpose remains meaningful, or
|
59 |
+
|
60 |
+
b) under the GNU GPL, with none of the additional permissions of
|
61 |
+
this License applicable to that copy.
|
62 |
+
|
63 |
+
3. Object Code Incorporating Material from Library Header Files.
|
64 |
+
|
65 |
+
The object code form of an Application may incorporate material from
|
66 |
+
a header file that is part of the Library. You may convey such object
|
67 |
+
code under terms of your choice, provided that, if the incorporated
|
68 |
+
material is not limited to numerical parameters, data structure
|
69 |
+
layouts and accessors, or small macros, inline functions and templates
|
70 |
+
(ten or fewer lines in length), you do both of the following:
|
71 |
+
|
72 |
+
a) Give prominent notice with each copy of the object code that the
|
73 |
+
Library is used in it and that the Library and its use are
|
74 |
+
covered by this License.
|
75 |
+
|
76 |
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77 |
+
document.
|
78 |
+
|
79 |
+
4. Combined Works.
|
80 |
+
|
81 |
+
You may convey a Combined Work under terms of your choice that,
|
82 |
+
taken together, effectively do not restrict modification of the
|
83 |
+
portions of the Library contained in the Combined Work and reverse
|
84 |
+
engineering for debugging such modifications, if you also do each of
|
85 |
+
the following:
|
86 |
+
|
87 |
+
a) Give prominent notice with each copy of the Combined Work that
|
88 |
+
the Library is used in it and that the Library and its use are
|
89 |
+
covered by this License.
|
90 |
+
|
91 |
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92 |
+
document.
|
93 |
+
|
94 |
+
c) For a Combined Work that displays copyright notices during
|
95 |
+
execution, include the copyright notice for the Library among
|
96 |
+
these notices, as well as a reference directing the user to the
|
97 |
+
copies of the GNU GPL and this license document.
|
98 |
+
|
99 |
+
d) Do one of the following:
|
100 |
+
|
101 |
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102 |
+
License, and the Corresponding Application Code in a form
|
103 |
+
suitable for, and under terms that permit, the user to
|
104 |
+
recombine or relink the Application with a modified version of
|
105 |
+
the Linked Version to produce a modified Combined Work, in the
|
106 |
+
manner specified by section 6 of the GNU GPL for conveying
|
107 |
+
Corresponding Source.
|
108 |
+
|
109 |
+
1) Use a suitable shared library mechanism for linking with the
|
110 |
+
Library. A suitable mechanism is one that (a) uses at run time
|
111 |
+
a copy of the Library already present on the user's computer
|
112 |
+
system, and (b) will operate properly with a modified version
|
113 |
+
of the Library that is interface-compatible with the Linked
|
114 |
+
Version.
|
115 |
+
|
116 |
+
e) Provide Installation Information, but only if you would otherwise
|
117 |
+
be required to provide such information under section 6 of the
|
118 |
+
GNU GPL, and only to the extent that such information is
|
119 |
+
necessary to install and execute a modified version of the
|
120 |
+
Combined Work produced by recombining or relinking the
|
121 |
+
Application with a modified version of the Linked Version. (If
|
122 |
+
you use option 4d0, the Installation Information must accompany
|
123 |
+
the Minimal Corresponding Source and Corresponding Application
|
124 |
+
Code. If you use option 4d1, you must provide the Installation
|
125 |
+
Information in the manner specified by section 6 of the GNU GPL
|
126 |
+
for conveying Corresponding Source.)
|
127 |
+
|
128 |
+
5. Combined Libraries.
|
129 |
+
|
130 |
+
You may place library facilities that are a work based on the
|
131 |
+
Library side by side in a single library together with other library
|
132 |
+
facilities that are not Applications and are not covered by this
|
133 |
+
License, and convey such a combined library under terms of your
|
134 |
+
choice, if you do both of the following:
|
135 |
+
|
136 |
+
a) Accompany the combined library with a copy of the same work based
|
137 |
+
on the Library, uncombined with any other library facilities,
|
138 |
+
conveyed under the terms of this License.
|
139 |
+
|
140 |
+
b) Give prominent notice with the combined library that part of it
|
141 |
+
is a work based on the Library, and explaining where to find the
|
142 |
+
accompanying uncombined form of the same work.
|
143 |
+
|
144 |
+
6. Revised Versions of the GNU Lesser General Public License.
|
145 |
+
|
146 |
+
The Free Software Foundation may publish revised and/or new versions
|
147 |
+
of the GNU Lesser General Public License from time to time. Such new
|
148 |
+
versions will be similar in spirit to the present version, but may
|
149 |
+
differ in detail to address new problems or concerns.
|
150 |
+
|
151 |
+
Each version is given a distinguishing version number. If the
|
152 |
+
Library as you received it specifies that a certain numbered version
|
153 |
+
of the GNU Lesser General Public License "or any later version"
|
154 |
+
applies to it, you have the option of following the terms and
|
155 |
+
conditions either of that published version or of any later version
|
156 |
+
published by the Free Software Foundation. If the Library as you
|
157 |
+
received it does not specify a version number of the GNU Lesser
|
158 |
+
General Public License, you may choose any version of the GNU Lesser
|
159 |
+
General Public License ever published by the Free Software Foundation.
|
160 |
+
|
161 |
+
If the Library as you received it specifies that a proxy can decide
|
162 |
+
whether future versions of the GNU Lesser General Public License shall
|
163 |
+
apply, that proxy's public statement of acceptance of any version is
|
164 |
+
permanent authorization for you to choose that version for the
|
165 |
+
Library.
|
LICENSE
ADDED
@@ -0,0 +1,661 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 19 November 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU Affero General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works, specifically designed to ensure
|
12 |
+
cooperation with the community in the case of network server software.
|
13 |
+
|
14 |
+
The licenses for most software and other practical works are designed
|
15 |
+
to take away your freedom to share and change the works. By contrast,
|
16 |
+
our General Public Licenses are intended to guarantee your freedom to
|
17 |
+
share and change all versions of a program--to make sure it remains free
|
18 |
+
software for all its users.
|
19 |
+
|
20 |
+
When we speak of free software, we are referring to freedom, not
|
21 |
+
price. Our General Public Licenses are designed to make sure that you
|
22 |
+
have the freedom to distribute copies of free software (and charge for
|
23 |
+
them if you wish), that you receive source code or can get it if you
|
24 |
+
want it, that you can change the software or use pieces of it in new
|
25 |
+
free programs, and that you know you can do these things.
|
26 |
+
|
27 |
+
Developers that use our General Public Licenses protect your rights
|
28 |
+
with two steps: (1) assert copyright on the software, and (2) offer
|
29 |
+
you this License which gives you legal permission to copy, distribute
|
30 |
+
and/or modify the software.
|
31 |
+
|
32 |
+
A secondary benefit of defending all users' freedom is that
|
33 |
+
improvements made in alternate versions of the program, if they
|
34 |
+
receive widespread use, become available for other developers to
|
35 |
+
incorporate. Many developers of free software are heartened and
|
36 |
+
encouraged by the resulting cooperation. However, in the case of
|
37 |
+
software used on network servers, this result may fail to come about.
|
38 |
+
The GNU General Public License permits making a modified version and
|
39 |
+
letting the public access it on a server without ever releasing its
|
40 |
+
source code to the public.
|
41 |
+
|
42 |
+
The GNU Affero General Public License is designed specifically to
|
43 |
+
ensure that, in such cases, the modified source code becomes available
|
44 |
+
to the community. It requires the operator of a network server to
|
45 |
+
provide the source code of the modified version running there to the
|
46 |
+
users of that server. Therefore, public use of a modified version, on
|
47 |
+
a publicly accessible server, gives the public access to the source
|
48 |
+
code of the modified version.
|
49 |
+
|
50 |
+
An older license, called the Affero General Public License and
|
51 |
+
published by Affero, was designed to accomplish similar goals. This is
|
52 |
+
a different license, not a version of the Affero GPL, but Affero has
|
53 |
+
released a new version of the Affero GPL which permits relicensing under
|
54 |
+
this license.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
TERMS AND CONDITIONS
|
60 |
+
|
61 |
+
0. Definitions.
|
62 |
+
|
63 |
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
64 |
+
|
65 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
66 |
+
works, such as semiconductor masks.
|
67 |
+
|
68 |
+
"The Program" refers to any copyrightable work licensed under this
|
69 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
70 |
+
"recipients" may be individuals or organizations.
|
71 |
+
|
72 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
73 |
+
in a fashion requiring copyright permission, other than the making of an
|
74 |
+
exact copy. The resulting work is called a "modified version" of the
|
75 |
+
earlier work or a work "based on" the earlier work.
|
76 |
+
|
77 |
+
A "covered work" means either the unmodified Program or a work based
|
78 |
+
on the Program.
|
79 |
+
|
80 |
+
To "propagate" a work means to do anything with it that, without
|
81 |
+
permission, would make you directly or secondarily liable for
|
82 |
+
infringement under applicable copyright law, except executing it on a
|
83 |
+
computer or modifying a private copy. Propagation includes copying,
|
84 |
+
distribution (with or without modification), making available to the
|
85 |
+
public, and in some countries other activities as well.
|
86 |
+
|
87 |
+
To "convey" a work means any kind of propagation that enables other
|
88 |
+
parties to make or receive copies. Mere interaction with a user through
|
89 |
+
a computer network, with no transfer of a copy, is not conveying.
|
90 |
+
|
91 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
92 |
+
to the extent that it includes a convenient and prominently visible
|
93 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
94 |
+
tells the user that there is no warranty for the work (except to the
|
95 |
+
extent that warranties are provided), that licensees may convey the
|
96 |
+
work under this License, and how to view a copy of this License. If
|
97 |
+
the interface presents a list of user commands or options, such as a
|
98 |
+
menu, a prominent item in the list meets this criterion.
|
99 |
+
|
100 |
+
1. Source Code.
|
101 |
+
|
102 |
+
The "source code" for a work means the preferred form of the work
|
103 |
+
for making modifications to it. "Object code" means any non-source
|
104 |
+
form of a work.
|
105 |
+
|
106 |
+
A "Standard Interface" means an interface that either is an official
|
107 |
+
standard defined by a recognized standards body, or, in the case of
|
108 |
+
interfaces specified for a particular programming language, one that
|
109 |
+
is widely used among developers working in that language.
|
110 |
+
|
111 |
+
The "System Libraries" of an executable work include anything, other
|
112 |
+
than the work as a whole, that (a) is included in the normal form of
|
113 |
+
packaging a Major Component, but which is not part of that Major
|
114 |
+
Component, and (b) serves only to enable use of the work with that
|
115 |
+
Major Component, or to implement a Standard Interface for which an
|
116 |
+
implementation is available to the public in source code form. A
|
117 |
+
"Major Component", in this context, means a major essential component
|
118 |
+
(kernel, window system, and so on) of the specific operating system
|
119 |
+
(if any) on which the executable work runs, or a compiler used to
|
120 |
+
produce the work, or an object code interpreter used to run it.
|
121 |
+
|
122 |
+
The "Corresponding Source" for a work in object code form means all
|
123 |
+
the source code needed to generate, install, and (for an executable
|
124 |
+
work) run the object code and to modify the work, including scripts to
|
125 |
+
control those activities. However, it does not include the work's
|
126 |
+
System Libraries, or general-purpose tools or generally available free
|
127 |
+
programs which are used unmodified in performing those activities but
|
128 |
+
which are not part of the work. For example, Corresponding Source
|
129 |
+
includes interface definition files associated with source files for
|
130 |
+
the work, and the source code for shared libraries and dynamically
|
131 |
+
linked subprograms that the work is specifically designed to require,
|
132 |
+
such as by intimate data communication or control flow between those
|
133 |
+
subprograms and other parts of the work.
|
134 |
+
|
135 |
+
The Corresponding Source need not include anything that users
|
136 |
+
can regenerate automatically from other parts of the Corresponding
|
137 |
+
Source.
|
138 |
+
|
139 |
+
The Corresponding Source for a work in source code form is that
|
140 |
+
same work.
|
141 |
+
|
142 |
+
2. Basic Permissions.
|
143 |
+
|
144 |
+
All rights granted under this License are granted for the term of
|
145 |
+
copyright on the Program, and are irrevocable provided the stated
|
146 |
+
conditions are met. This License explicitly affirms your unlimited
|
147 |
+
permission to run the unmodified Program. The output from running a
|
148 |
+
covered work is covered by this License only if the output, given its
|
149 |
+
content, constitutes a covered work. This License acknowledges your
|
150 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
151 |
+
|
152 |
+
You may make, run and propagate covered works that you do not
|
153 |
+
convey, without conditions so long as your license otherwise remains
|
154 |
+
in force. You may convey covered works to others for the sole purpose
|
155 |
+
of having them make modifications exclusively for you, or provide you
|
156 |
+
with facilities for running those works, provided that you comply with
|
157 |
+
the terms of this License in conveying all material for which you do
|
158 |
+
not control copyright. Those thus making or running the covered works
|
159 |
+
for you must do so exclusively on your behalf, under your direction
|
160 |
+
and control, on terms that prohibit them from making any copies of
|
161 |
+
your copyrighted material outside their relationship with you.
|
162 |
+
|
163 |
+
Conveying under any other circumstances is permitted solely under
|
164 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
165 |
+
makes it unnecessary.
|
166 |
+
|
167 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
168 |
+
|
169 |
+
No covered work shall be deemed part of an effective technological
|
170 |
+
measure under any applicable law fulfilling obligations under article
|
171 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
172 |
+
similar laws prohibiting or restricting circumvention of such
|
173 |
+
measures.
|
174 |
+
|
175 |
+
When you convey a covered work, you waive any legal power to forbid
|
176 |
+
circumvention of technological measures to the extent such circumvention
|
177 |
+
is effected by exercising rights under this License with respect to
|
178 |
+
the covered work, and you disclaim any intention to limit operation or
|
179 |
+
modification of the work as a means of enforcing, against the work's
|
180 |
+
users, your or third parties' legal rights to forbid circumvention of
|
181 |
+
technological measures.
|
182 |
+
|
183 |
+
4. Conveying Verbatim Copies.
|
184 |
+
|
185 |
+
You may convey verbatim copies of the Program's source code as you
|
186 |
+
receive it, in any medium, provided that you conspicuously and
|
187 |
+
appropriately publish on each copy an appropriate copyright notice;
|
188 |
+
keep intact all notices stating that this License and any
|
189 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
190 |
+
keep intact all notices of the absence of any warranty; and give all
|
191 |
+
recipients a copy of this License along with the Program.
|
192 |
+
|
193 |
+
You may charge any price or no price for each copy that you convey,
|
194 |
+
and you may offer support or warranty protection for a fee.
|
195 |
+
|
196 |
+
5. Conveying Modified Source Versions.
|
197 |
+
|
198 |
+
You may convey a work based on the Program, or the modifications to
|
199 |
+
produce it from the Program, in the form of source code under the
|
200 |
+
terms of section 4, provided that you also meet all of these conditions:
|
201 |
+
|
202 |
+
a) The work must carry prominent notices stating that you modified
|
203 |
+
it, and giving a relevant date.
|
204 |
+
|
205 |
+
b) The work must carry prominent notices stating that it is
|
206 |
+
released under this License and any conditions added under section
|
207 |
+
7. This requirement modifies the requirement in section 4 to
|
208 |
+
"keep intact all notices".
|
209 |
+
|
210 |
+
c) You must license the entire work, as a whole, under this
|
211 |
+
License to anyone who comes into possession of a copy. This
|
212 |
+
License will therefore apply, along with any applicable section 7
|
213 |
+
additional terms, to the whole of the work, and all its parts,
|
214 |
+
regardless of how they are packaged. This License gives no
|
215 |
+
permission to license the work in any other way, but it does not
|
216 |
+
invalidate such permission if you have separately received it.
|
217 |
+
|
218 |
+
d) If the work has interactive user interfaces, each must display
|
219 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
220 |
+
interfaces that do not display Appropriate Legal Notices, your
|
221 |
+
work need not make them do so.
|
222 |
+
|
223 |
+
A compilation of a covered work with other separate and independent
|
224 |
+
works, which are not by their nature extensions of the covered work,
|
225 |
+
and which are not combined with it such as to form a larger program,
|
226 |
+
in or on a volume of a storage or distribution medium, is called an
|
227 |
+
"aggregate" if the compilation and its resulting copyright are not
|
228 |
+
used to limit the access or legal rights of the compilation's users
|
229 |
+
beyond what the individual works permit. Inclusion of a covered work
|
230 |
+
in an aggregate does not cause this License to apply to the other
|
231 |
+
parts of the aggregate.
|
232 |
+
|
233 |
+
6. Conveying Non-Source Forms.
|
234 |
+
|
235 |
+
You may convey a covered work in object code form under the terms
|
236 |
+
of sections 4 and 5, provided that you also convey the
|
237 |
+
machine-readable Corresponding Source under the terms of this License,
|
238 |
+
in one of these ways:
|
239 |
+
|
240 |
+
a) Convey the object code in, or embodied in, a physical product
|
241 |
+
(including a physical distribution medium), accompanied by the
|
242 |
+
Corresponding Source fixed on a durable physical medium
|
243 |
+
customarily used for software interchange.
|
244 |
+
|
245 |
+
b) Convey the object code in, or embodied in, a physical product
|
246 |
+
(including a physical distribution medium), accompanied by a
|
247 |
+
written offer, valid for at least three years and valid for as
|
248 |
+
long as you offer spare parts or customer support for that product
|
249 |
+
model, to give anyone who possesses the object code either (1) a
|
250 |
+
copy of the Corresponding Source for all the software in the
|
251 |
+
product that is covered by this License, on a durable physical
|
252 |
+
medium customarily used for software interchange, for a price no
|
253 |
+
more than your reasonable cost of physically performing this
|
254 |
+
conveying of source, or (2) access to copy the
|
255 |
+
Corresponding Source from a network server at no charge.
|
256 |
+
|
257 |
+
c) Convey individual copies of the object code with a copy of the
|
258 |
+
written offer to provide the Corresponding Source. This
|
259 |
+
alternative is allowed only occasionally and noncommercially, and
|
260 |
+
only if you received the object code with such an offer, in accord
|
261 |
+
with subsection 6b.
|
262 |
+
|
263 |
+
d) Convey the object code by offering access from a designated
|
264 |
+
place (gratis or for a charge), and offer equivalent access to the
|
265 |
+
Corresponding Source in the same way through the same place at no
|
266 |
+
further charge. You need not require recipients to copy the
|
267 |
+
Corresponding Source along with the object code. If the place to
|
268 |
+
copy the object code is a network server, the Corresponding Source
|
269 |
+
may be on a different server (operated by you or a third party)
|
270 |
+
that supports equivalent copying facilities, provided you maintain
|
271 |
+
clear directions next to the object code saying where to find the
|
272 |
+
Corresponding Source. Regardless of what server hosts the
|
273 |
+
Corresponding Source, you remain obligated to ensure that it is
|
274 |
+
available for as long as needed to satisfy these requirements.
|
275 |
+
|
276 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
277 |
+
you inform other peers where the object code and Corresponding
|
278 |
+
Source of the work are being offered to the general public at no
|
279 |
+
charge under subsection 6d.
|
280 |
+
|
281 |
+
A separable portion of the object code, whose source code is excluded
|
282 |
+
from the Corresponding Source as a System Library, need not be
|
283 |
+
included in conveying the object code work.
|
284 |
+
|
285 |
+
A "User Product" is either (1) a "consumer product", which means any
|
286 |
+
tangible personal property which is normally used for personal, family,
|
287 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
288 |
+
into a dwelling. In determining whether a product is a consumer product,
|
289 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
290 |
+
product received by a particular user, "normally used" refers to a
|
291 |
+
typical or common use of that class of product, regardless of the status
|
292 |
+
of the particular user or of the way in which the particular user
|
293 |
+
actually uses, or expects or is expected to use, the product. A product
|
294 |
+
is a consumer product regardless of whether the product has substantial
|
295 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
296 |
+
the only significant mode of use of the product.
|
297 |
+
|
298 |
+
"Installation Information" for a User Product means any methods,
|
299 |
+
procedures, authorization keys, or other information required to install
|
300 |
+
and execute modified versions of a covered work in that User Product from
|
301 |
+
a modified version of its Corresponding Source. The information must
|
302 |
+
suffice to ensure that the continued functioning of the modified object
|
303 |
+
code is in no case prevented or interfered with solely because
|
304 |
+
modification has been made.
|
305 |
+
|
306 |
+
If you convey an object code work under this section in, or with, or
|
307 |
+
specifically for use in, a User Product, and the conveying occurs as
|
308 |
+
part of a transaction in which the right of possession and use of the
|
309 |
+
User Product is transferred to the recipient in perpetuity or for a
|
310 |
+
fixed term (regardless of how the transaction is characterized), the
|
311 |
+
Corresponding Source conveyed under this section must be accompanied
|
312 |
+
by the Installation Information. But this requirement does not apply
|
313 |
+
if neither you nor any third party retains the ability to install
|
314 |
+
modified object code on the User Product (for example, the work has
|
315 |
+
been installed in ROM).
|
316 |
+
|
317 |
+
The requirement to provide Installation Information does not include a
|
318 |
+
requirement to continue to provide support service, warranty, or updates
|
319 |
+
for a work that has been modified or installed by the recipient, or for
|
320 |
+
the User Product in which it has been modified or installed. Access to a
|
321 |
+
network may be denied when the modification itself materially and
|
322 |
+
adversely affects the operation of the network or violates the rules and
|
323 |
+
protocols for communication across the network.
|
324 |
+
|
325 |
+
Corresponding Source conveyed, and Installation Information provided,
|
326 |
+
in accord with this section must be in a format that is publicly
|
327 |
+
documented (and with an implementation available to the public in
|
328 |
+
source code form), and must require no special password or key for
|
329 |
+
unpacking, reading or copying.
|
330 |
+
|
331 |
+
7. Additional Terms.
|
332 |
+
|
333 |
+
"Additional permissions" are terms that supplement the terms of this
|
334 |
+
License by making exceptions from one or more of its conditions.
|
335 |
+
Additional permissions that are applicable to the entire Program shall
|
336 |
+
be treated as though they were included in this License, to the extent
|
337 |
+
that they are valid under applicable law. If additional permissions
|
338 |
+
apply only to part of the Program, that part may be used separately
|
339 |
+
under those permissions, but the entire Program remains governed by
|
340 |
+
this License without regard to the additional permissions.
|
341 |
+
|
342 |
+
When you convey a copy of a covered work, you may at your option
|
343 |
+
remove any additional permissions from that copy, or from any part of
|
344 |
+
it. (Additional permissions may be written to require their own
|
345 |
+
removal in certain cases when you modify the work.) You may place
|
346 |
+
additional permissions on material, added by you to a covered work,
|
347 |
+
for which you have or can give appropriate copyright permission.
|
348 |
+
|
349 |
+
Notwithstanding any other provision of this License, for material you
|
350 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
351 |
+
that material) supplement the terms of this License with terms:
|
352 |
+
|
353 |
+
a) Disclaiming warranty or limiting liability differently from the
|
354 |
+
terms of sections 15 and 16 of this License; or
|
355 |
+
|
356 |
+
b) Requiring preservation of specified reasonable legal notices or
|
357 |
+
author attributions in that material or in the Appropriate Legal
|
358 |
+
Notices displayed by works containing it; or
|
359 |
+
|
360 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
361 |
+
requiring that modified versions of such material be marked in
|
362 |
+
reasonable ways as different from the original version; or
|
363 |
+
|
364 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
365 |
+
authors of the material; or
|
366 |
+
|
367 |
+
e) Declining to grant rights under trademark law for use of some
|
368 |
+
trade names, trademarks, or service marks; or
|
369 |
+
|
370 |
+
f) Requiring indemnification of licensors and authors of that
|
371 |
+
material by anyone who conveys the material (or modified versions of
|
372 |
+
it) with contractual assumptions of liability to the recipient, for
|
373 |
+
any liability that these contractual assumptions directly impose on
|
374 |
+
those licensors and authors.
|
375 |
+
|
376 |
+
All other non-permissive additional terms are considered "further
|
377 |
+
restrictions" within the meaning of section 10. If the Program as you
|
378 |
+
received it, or any part of it, contains a notice stating that it is
|
379 |
+
governed by this License along with a term that is a further
|
380 |
+
restriction, you may remove that term. If a license document contains
|
381 |
+
a further restriction but permits relicensing or conveying under this
|
382 |
+
License, you may add to a covered work material governed by the terms
|
383 |
+
of that license document, provided that the further restriction does
|
384 |
+
not survive such relicensing or conveying.
|
385 |
+
|
386 |
+
If you add terms to a covered work in accord with this section, you
|
387 |
+
must place, in the relevant source files, a statement of the
|
388 |
+
additional terms that apply to those files, or a notice indicating
|
389 |
+
where to find the applicable terms.
|
390 |
+
|
391 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
392 |
+
form of a separately written license, or stated as exceptions;
|
393 |
+
the above requirements apply either way.
|
394 |
+
|
395 |
+
8. Termination.
|
396 |
+
|
397 |
+
You may not propagate or modify a covered work except as expressly
|
398 |
+
provided under this License. Any attempt otherwise to propagate or
|
399 |
+
modify it is void, and will automatically terminate your rights under
|
400 |
+
this License (including any patent licenses granted under the third
|
401 |
+
paragraph of section 11).
|
402 |
+
|
403 |
+
However, if you cease all violation of this License, then your
|
404 |
+
license from a particular copyright holder is reinstated (a)
|
405 |
+
provisionally, unless and until the copyright holder explicitly and
|
406 |
+
finally terminates your license, and (b) permanently, if the copyright
|
407 |
+
holder fails to notify you of the violation by some reasonable means
|
408 |
+
prior to 60 days after the cessation.
|
409 |
+
|
410 |
+
Moreover, your license from a particular copyright holder is
|
411 |
+
reinstated permanently if the copyright holder notifies you of the
|
412 |
+
violation by some reasonable means, this is the first time you have
|
413 |
+
received notice of violation of this License (for any work) from that
|
414 |
+
copyright holder, and you cure the violation prior to 30 days after
|
415 |
+
your receipt of the notice.
|
416 |
+
|
417 |
+
Termination of your rights under this section does not terminate the
|
418 |
+
licenses of parties who have received copies or rights from you under
|
419 |
+
this License. If your rights have been terminated and not permanently
|
420 |
+
reinstated, you do not qualify to receive new licenses for the same
|
421 |
+
material under section 10.
|
422 |
+
|
423 |
+
9. Acceptance Not Required for Having Copies.
|
424 |
+
|
425 |
+
You are not required to accept this License in order to receive or
|
426 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
427 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
428 |
+
to receive a copy likewise does not require acceptance. However,
|
429 |
+
nothing other than this License grants you permission to propagate or
|
430 |
+
modify any covered work. These actions infringe copyright if you do
|
431 |
+
not accept this License. Therefore, by modifying or propagating a
|
432 |
+
covered work, you indicate your acceptance of this License to do so.
|
433 |
+
|
434 |
+
10. Automatic Licensing of Downstream Recipients.
|
435 |
+
|
436 |
+
Each time you convey a covered work, the recipient automatically
|
437 |
+
receives a license from the original licensors, to run, modify and
|
438 |
+
propagate that work, subject to this License. You are not responsible
|
439 |
+
for enforcing compliance by third parties with this License.
|
440 |
+
|
441 |
+
An "entity transaction" is a transaction transferring control of an
|
442 |
+
organization, or substantially all assets of one, or subdividing an
|
443 |
+
organization, or merging organizations. If propagation of a covered
|
444 |
+
work results from an entity transaction, each party to that
|
445 |
+
transaction who receives a copy of the work also receives whatever
|
446 |
+
licenses to the work the party's predecessor in interest had or could
|
447 |
+
give under the previous paragraph, plus a right to possession of the
|
448 |
+
Corresponding Source of the work from the predecessor in interest, if
|
449 |
+
the predecessor has it or can get it with reasonable efforts.
|
450 |
+
|
451 |
+
You may not impose any further restrictions on the exercise of the
|
452 |
+
rights granted or affirmed under this License. For example, you may
|
453 |
+
not impose a license fee, royalty, or other charge for exercise of
|
454 |
+
rights granted under this License, and you may not initiate litigation
|
455 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
456 |
+
any patent claim is infringed by making, using, selling, offering for
|
457 |
+
sale, or importing the Program or any portion of it.
|
458 |
+
|
459 |
+
11. Patents.
|
460 |
+
|
461 |
+
A "contributor" is a copyright holder who authorizes use under this
|
462 |
+
License of the Program or a work on which the Program is based. The
|
463 |
+
work thus licensed is called the contributor's "contributor version".
|
464 |
+
|
465 |
+
A contributor's "essential patent claims" are all patent claims
|
466 |
+
owned or controlled by the contributor, whether already acquired or
|
467 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
468 |
+
by this License, of making, using, or selling its contributor version,
|
469 |
+
but do not include claims that would be infringed only as a
|
470 |
+
consequence of further modification of the contributor version. For
|
471 |
+
purposes of this definition, "control" includes the right to grant
|
472 |
+
patent sublicenses in a manner consistent with the requirements of
|
473 |
+
this License.
|
474 |
+
|
475 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
476 |
+
patent license under the contributor's essential patent claims, to
|
477 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
478 |
+
propagate the contents of its contributor version.
|
479 |
+
|
480 |
+
In the following three paragraphs, a "patent license" is any express
|
481 |
+
agreement or commitment, however denominated, not to enforce a patent
|
482 |
+
(such as an express permission to practice a patent or covenant not to
|
483 |
+
sue for patent infringement). To "grant" such a patent license to a
|
484 |
+
party means to make such an agreement or commitment not to enforce a
|
485 |
+
patent against the party.
|
486 |
+
|
487 |
+
If you convey a covered work, knowingly relying on a patent license,
|
488 |
+
and the Corresponding Source of the work is not available for anyone
|
489 |
+
to copy, free of charge and under the terms of this License, through a
|
490 |
+
publicly available network server or other readily accessible means,
|
491 |
+
then you must either (1) cause the Corresponding Source to be so
|
492 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
493 |
+
patent license for this particular work, or (3) arrange, in a manner
|
494 |
+
consistent with the requirements of this License, to extend the patent
|
495 |
+
license to downstream recipients. "Knowingly relying" means you have
|
496 |
+
actual knowledge that, but for the patent license, your conveying the
|
497 |
+
covered work in a country, or your recipient's use of the covered work
|
498 |
+
in a country, would infringe one or more identifiable patents in that
|
499 |
+
country that you have reason to believe are valid.
|
500 |
+
|
501 |
+
If, pursuant to or in connection with a single transaction or
|
502 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
503 |
+
covered work, and grant a patent license to some of the parties
|
504 |
+
receiving the covered work authorizing them to use, propagate, modify
|
505 |
+
or convey a specific copy of the covered work, then the patent license
|
506 |
+
you grant is automatically extended to all recipients of the covered
|
507 |
+
work and works based on it.
|
508 |
+
|
509 |
+
A patent license is "discriminatory" if it does not include within
|
510 |
+
the scope of its coverage, prohibits the exercise of, or is
|
511 |
+
conditioned on the non-exercise of one or more of the rights that are
|
512 |
+
specifically granted under this License. You may not convey a covered
|
513 |
+
work if you are a party to an arrangement with a third party that is
|
514 |
+
in the business of distributing software, under which you make payment
|
515 |
+
to the third party based on the extent of your activity of conveying
|
516 |
+
the work, and under which the third party grants, to any of the
|
517 |
+
parties who would receive the covered work from you, a discriminatory
|
518 |
+
patent license (a) in connection with copies of the covered work
|
519 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
520 |
+
for and in connection with specific products or compilations that
|
521 |
+
contain the covered work, unless you entered into that arrangement,
|
522 |
+
or that patent license was granted, prior to 28 March 2007.
|
523 |
+
|
524 |
+
Nothing in this License shall be construed as excluding or limiting
|
525 |
+
any implied license or other defenses to infringement that may
|
526 |
+
otherwise be available to you under applicable patent law.
|
527 |
+
|
528 |
+
12. No Surrender of Others' Freedom.
|
529 |
+
|
530 |
+
If conditions are imposed on you (whether by court order, agreement or
|
531 |
+
otherwise) that contradict the conditions of this License, they do not
|
532 |
+
excuse you from the conditions of this License. If you cannot convey a
|
533 |
+
covered work so as to satisfy simultaneously your obligations under this
|
534 |
+
License and any other pertinent obligations, then as a consequence you may
|
535 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
536 |
+
to collect a royalty for further conveying from those to whom you convey
|
537 |
+
the Program, the only way you could satisfy both those terms and this
|
538 |
+
License would be to refrain entirely from conveying the Program.
|
539 |
+
|
540 |
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
541 |
+
|
542 |
+
Notwithstanding any other provision of this License, if you modify the
|
543 |
+
Program, your modified version must prominently offer all users
|
544 |
+
interacting with it remotely through a computer network (if your version
|
545 |
+
supports such interaction) an opportunity to receive the Corresponding
|
546 |
+
Source of your version by providing access to the Corresponding Source
|
547 |
+
from a network server at no charge, through some standard or customary
|
548 |
+
means of facilitating copying of software. This Corresponding Source
|
549 |
+
shall include the Corresponding Source for any work covered by version 3
|
550 |
+
of the GNU General Public License that is incorporated pursuant to the
|
551 |
+
following paragraph.
|
552 |
+
|
553 |
+
Notwithstanding any other provision of this License, you have
|
554 |
+
permission to link or combine any covered work with a work licensed
|
555 |
+
under version 3 of the GNU General Public License into a single
|
556 |
+
combined work, and to convey the resulting work. The terms of this
|
557 |
+
License will continue to apply to the part which is the covered work,
|
558 |
+
but the work with which it is combined will remain governed by version
|
559 |
+
3 of the GNU General Public License.
|
560 |
+
|
561 |
+
14. Revised Versions of this License.
|
562 |
+
|
563 |
+
The Free Software Foundation may publish revised and/or new versions of
|
564 |
+
the GNU Affero General Public License from time to time. Such new versions
|
565 |
+
will be similar in spirit to the present version, but may differ in detail to
|
566 |
+
address new problems or concerns.
|
567 |
+
|
568 |
+
Each version is given a distinguishing version number. If the
|
569 |
+
Program specifies that a certain numbered version of the GNU Affero General
|
570 |
+
Public License "or any later version" applies to it, you have the
|
571 |
+
option of following the terms and conditions either of that numbered
|
572 |
+
version or of any later version published by the Free Software
|
573 |
+
Foundation. If the Program does not specify a version number of the
|
574 |
+
GNU Affero General Public License, you may choose any version ever published
|
575 |
+
by the Free Software Foundation.
|
576 |
+
|
577 |
+
If the Program specifies that a proxy can decide which future
|
578 |
+
versions of the GNU Affero General Public License can be used, that proxy's
|
579 |
+
public statement of acceptance of a version permanently authorizes you
|
580 |
+
to choose that version for the Program.
|
581 |
+
|
582 |
+
Later license versions may give you additional or different
|
583 |
+
permissions. However, no additional obligations are imposed on any
|
584 |
+
author or copyright holder as a result of your choosing to follow a
|
585 |
+
later version.
|
586 |
+
|
587 |
+
15. Disclaimer of Warranty.
|
588 |
+
|
589 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
590 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
591 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
592 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
593 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
594 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
595 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
596 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
597 |
+
|
598 |
+
16. Limitation of Liability.
|
599 |
+
|
600 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
601 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
602 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
603 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
604 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
605 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
606 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
607 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
608 |
+
SUCH DAMAGES.
|
609 |
+
|
610 |
+
17. Interpretation of Sections 15 and 16.
|
611 |
+
|
612 |
+
If the disclaimer of warranty and limitation of liability provided
|
613 |
+
above cannot be given local legal effect according to their terms,
|
614 |
+
reviewing courts shall apply local law that most closely approximates
|
615 |
+
an absolute waiver of all civil liability in connection with the
|
616 |
+
Program, unless a warranty or assumption of liability accompanies a
|
617 |
+
copy of the Program in return for a fee.
|
618 |
+
|
619 |
+
END OF TERMS AND CONDITIONS
|
620 |
+
|
621 |
+
How to Apply These Terms to Your New Programs
|
622 |
+
|
623 |
+
If you develop a new program, and you want it to be of the greatest
|
624 |
+
possible use to the public, the best way to achieve this is to make it
|
625 |
+
free software which everyone can redistribute and change under these terms.
|
626 |
+
|
627 |
+
To do so, attach the following notices to the program. It is safest
|
628 |
+
to attach them to the start of each source file to most effectively
|
629 |
+
state the exclusion of warranty; and each file should have at least
|
630 |
+
the "copyright" line and a pointer to where the full notice is found.
|
631 |
+
|
632 |
+
<one line to give the program's name and a brief idea of what it does.>
|
633 |
+
Copyright (C) <year> <name of author>
|
634 |
+
|
635 |
+
This program is free software: you can redistribute it and/or modify
|
636 |
+
it under the terms of the GNU Affero General Public License as published
|
637 |
+
by the Free Software Foundation, either version 3 of the License, or
|
638 |
+
(at your option) any later version.
|
639 |
+
|
640 |
+
This program is distributed in the hope that it will be useful,
|
641 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
642 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
643 |
+
GNU Affero General Public License for more details.
|
644 |
+
|
645 |
+
You should have received a copy of the GNU Affero General Public License
|
646 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
647 |
+
|
648 |
+
Also add information on how to contact you by electronic and paper mail.
|
649 |
+
|
650 |
+
If your software can interact with users remotely through a computer
|
651 |
+
network, you should also make sure that it provides a way for users to
|
652 |
+
get its source. For example, if your program is a web application, its
|
653 |
+
interface could display a "Source" link that leads users to an archive
|
654 |
+
of the code. There are many ways you could offer source, and different
|
655 |
+
solutions will be better for different programs; see section 13 for the
|
656 |
+
specific requirements.
|
657 |
+
|
658 |
+
You should also get your employer (if you work as a programmer) or school,
|
659 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
660 |
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
661 |
+
<https://www.gnu.org/licenses/>.
|
README.md
CHANGED
@@ -1,12 +1,245 @@
|
|
1 |
---
|
2 |
-
title: Style
|
3 |
-
emoji: 🚀
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: indigo
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 4.29.0
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
1 |
---
|
2 |
+
title: Style-Bert-VITS2
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 4.23.0
|
6 |
---
|
7 |
+
# Style-Bert-VITS2
|
8 |
+
|
9 |
+
Bert-VITS2 with more controllable voice styles.
|
10 |
+
|
11 |
+
https://github.com/litagin02/Style-Bert-VITS2/assets/139731664/e853f9a2-db4a-4202-a1dd-56ded3c562a0
|
12 |
+
|
13 |
+
You can install via `pip install style-bert-vits2` (inference only), see [library.ipynb](/library.ipynb) for example usage.
|
14 |
+
|
15 |
+
- **解説チュートリアル動画** [YouTube](https://youtu.be/aTUSzgDl1iY) [ニコニコ動画](https://www.nicovideo.jp/watch/sm43391524)
|
16 |
+
- [English README](docs/README_en.md)
|
17 |
+
- [](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
|
18 |
+
- [🤗 オンラインデモはこちらから](https://huggingface.co/spaces/litagin/Style-Bert-VITS2-Editor-Demo)
|
19 |
+
- [Zennの解説記事](https://zenn.dev/litagin/articles/034819a5256ff4)
|
20 |
+
|
21 |
+
- [**リリースページ**](https://github.com/litagin02/Style-Bert-VITS2/releases/)、[更新履歴](/docs/CHANGELOG.md)
|
22 |
+
|
23 |
+
- 2024-03-16: ver 2.4.1 (**batファイルによるインストール方法の変更**)
|
24 |
+
- 2024-03-15: ver 2.4.0 (大規模リファクタリングや種々の改良、ライブラリ化)
|
25 |
+
- 2024-02-26: ver 2.3 (辞書機能とエディター機能)
|
26 |
+
- 2024-02-09: ver 2.2
|
27 |
+
- 2024-02-07: ver 2.1
|
28 |
+
- 2024-02-03: ver 2.0 (JP-Extra)
|
29 |
+
- 2024-01-09: ver 1.3
|
30 |
+
- 2023-12-31: ver 1.2
|
31 |
+
- 2023-12-29: ver 1.1
|
32 |
+
- 2023-12-27: ver 1.0
|
33 |
+
|
34 |
+
This repository is based on [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2) v2.1 and Japanese-Extra, so many thanks to the original author!
|
35 |
+
|
36 |
+
**概要**
|
37 |
+
|
38 |
+
- 入力されたテキストの内容をもとに感情豊かな音声を生成する[Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)のv2.1とJapanese-Extraを元に、感情や発話スタイルを強弱込みで自由に制御できるようにしたものです。
|
39 |
+
- GitやPythonがない人でも(Windowsユーザーなら)簡単にインストールでき、学習もできます (多くを[EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2/)からお借りしました)。またGoogle Colabでの学習もサポートしています: [](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
|
40 |
+
- 音声合成のみに使う場合は、グラボがなくてもCPUで動作します。
|
41 |
+
- 他との連携に使えるAPIサーバーも同梱しています ([@darai0512](https://github.com/darai0512) 様によるPRです、ありがとうございます)。
|
42 |
+
- 元々「楽しそうな文章は楽しそうに、悲しそうな文章は悲しそうに」読むのがBert-VITS2の強みですので、スタイル指定がデフォルトでも感情豊かな音声を生成することができます。
|
43 |
+
|
44 |
+
|
45 |
+
## 使い方
|
46 |
+
|
47 |
+
CLIでの使い方は[こちら](/docs/CLI.md)を参照してください。
|
48 |
+
|
49 |
+
### 動作環境
|
50 |
+
|
51 |
+
各UIとAPI Serverにおいて、Windows コマンドプロンプト・WSL2・Linux(Ubuntu Desktop)での動作を確認しています(WSLでのパス指定は相対パスなど工夫ください)。NVidiaのGPUが無い場合は学習はできませんが音声合成とマージは可能です。
|
52 |
+
|
53 |
+
### インストール
|
54 |
+
|
55 |
+
Pythonライブラリとしてのpipでのインストールや使用例は[library.ipynb](/library.ipynb)を参照してください。
|
56 |
+
|
57 |
+
#### GitやPythonに馴染みが無い方
|
58 |
+
|
59 |
+
Windowsを前提としています。
|
60 |
+
|
61 |
+
1. [このzipファイル](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.4.1/sbv2.zip)を**パスに日本語や空白が含まれない場所に**ダウンロードして展開します。
|
62 |
+
- グラボがある方は、`Install-Style-Bert-VITS2.bat`をダブルクリックします。
|
63 |
+
- グラボがない方は、`Install-Style-Bert-VITS2-CPU.bat`をダブルクリックします。CPU版では学習はできませんが、音声合成とマージは可能です。
|
64 |
+
2. 待つと自動で必要な環境がインストールされます。
|
65 |
+
3. その後、自動的に音声合成するためのエディターが起動したらインストール成功です。デフォルトのモデルがダウンロードされるているので、そのまま遊ぶことができます。
|
66 |
+
|
67 |
+
またアップデートをしたい場合は、`Update-Style-Bert-VITS2.bat`をダブルクリックしてください。
|
68 |
+
|
69 |
+
ただし2024-03-16の**2.4.1**バージョン未満からのアップデートの場合は、全てを削除してから再びインストールする必要があります。申し訳ありません。移行方法は[CHANGELOG.md](/docs/CHANGELOG.md)を参照してください。
|
70 |
+
|
71 |
+
#### GitやPython使える人
|
72 |
+
|
73 |
+
```bash
|
74 |
+
git clone https://github.com/litagin02/Style-Bert-VITS2.git
|
75 |
+
cd Style-Bert-VITS2
|
76 |
+
python -m venv venv
|
77 |
+
venv\Scripts\activate
|
78 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
79 |
+
pip install -r requirements.txt
|
80 |
+
python initialize.py # 必要なモデルとデフォルトTTSモデルをダウンロード
|
81 |
+
```
|
82 |
+
最後を忘れずに。
|
83 |
+
|
84 |
+
### 音声合成
|
85 |
+
|
86 |
+
音声合成エディターは`Editor.bat`をダブルクリックか、`python server_editor.py --inbrowser`すると起動します(`--device cpu`でCPUモードで起動)。画面内で各セリフごとに設定を変えて原稿を作ったり、保存や読み込みや辞書の編集等ができます。
|
87 |
+
インストール時にデフォルトのモデルがダウンロードされているので、学習していなくてもそれを使うことができます。
|
88 |
+
|
89 |
+
エディター部分は[別リポジトリ](https://github.com/litagin02/Style-Bert-VITS2-Editor)に分かれています。
|
90 |
+
|
91 |
+
バージョン2.2以前での音声合成WebUIは、`App.bat`をダブルクリックか、`python app.py`するとWebUIが起動します。
|
92 |
+
|
93 |
+
音声合成に必要なモデルファイルたちの構造は以下の通りです(手動で配置する必要はありません)。
|
94 |
+
```
|
95 |
+
model_assets
|
96 |
+
├── your_model
|
97 |
+
│ ├── config.json
|
98 |
+
│ ├── your_model_file1.safetensors
|
99 |
+
│ ├── your_model_file2.safetensors
|
100 |
+
│ ├── ...
|
101 |
+
│ └── style_vectors.npy
|
102 |
+
└── another_model
|
103 |
+
├── ...
|
104 |
+
```
|
105 |
+
このように、推論には`config.json`と`*.safetensors`と`style_vectors.npy`が必要です。モデルを共有する場合は、この3つのファイルを共有してください。
|
106 |
+
|
107 |
+
このうち`style_vectors.npy`はスタイルを制御するために必要なファイルで、学習の時にデフォルトで平均スタイル「Neutral」が生成されます。
|
108 |
+
複数スタイルを使ってより詳しくスタイルを制御したい方は、下の「スタイルの生成」を参照してください(平均スタイルのみでも、学習データが感情豊かならば十分感情豊かな音声が生成されます)。
|
109 |
+
|
110 |
+
### 学習
|
111 |
+
|
112 |
+
- CLIでの学習の詳細は[こちら](docs/CLI.md)を参照してください。
|
113 |
+
- paperspace上での学習の詳細は[こちら](docs/paperspace.md)、colabでの学習は[こちら](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)を参照してください。
|
114 |
+
|
115 |
+
学習には2-14秒程度の音声ファイルが複数と、それらの書き起こしデータが必要です。
|
116 |
+
|
117 |
+
- 既存コーパスなどですでに分割された音声ファイルと書き起こしデータがある場合はそのまま(必要に応じて書き起こしファイルを修正して)使えます。下の「学習WebUI」を参照してください。
|
118 |
+
- そうでない場合、(長さは問わない)音声ファイルのみがあれば、そこから学習にすぐに使えるようにデータセットを作るためのツールを同梱しています。
|
119 |
+
|
120 |
+
#### データセット作り
|
121 |
+
|
122 |
+
- `App.bat`をダブルクリックか`python app.py`したところの「データセット作成」タブから、音声ファイルを適切な長さにスライスし、その後に文字の書き起こしを自動で行えます。
|
123 |
+
- 指示に従った後、下の「学習」タブでそのまま学習を行うことができます。
|
124 |
+
|
125 |
+
注意: データセットの手動修正やノイズ除去等、細かい修正を行いたい場合は[Aivis](https://github.com/tsukumijima/Aivis)や、そのデータセット部分のWindows対応版 [Aivis Dataset](https://github.com/litagin02/Aivis-Dataset) を使うといいかもしれません。ですがファイル数が多い場合などは、このツールで簡易的に切り出してデータセットを作るだけでも十分という気もしています。
|
126 |
+
|
127 |
+
データセットがどのようなものがいいかは各自試行錯誤中してください。
|
128 |
+
|
129 |
+
#### 学習WebUI
|
130 |
+
|
131 |
+
- `App.bat`をダブルクリックか`python app.py`して開くWebUIの「学習」タブから指示に従ってください。
|
132 |
+
|
133 |
+
### スタイルの生成
|
134 |
+
|
135 |
+
- デフォルトスタイル「Neutral」以外のスタイルを使いたい人向けです。
|
136 |
+
- `App.bat`をダブルクリックか`python app.py`して開くWebUIの「スタイル作成」タブから、音声ファイルを使ってスタイルを生成できます。
|
137 |
+
- 学習とは独立しているので、学習中でもできるし、学習が終わっても何度もやりなおせます(前処理は終わらせている必要があります)。
|
138 |
+
- スタイルについての仕様の詳細は[clustering.ipynb](clustering.ipynb)を参照してください。
|
139 |
+
|
140 |
+
### API Server
|
141 |
+
|
142 |
+
構築した環境下で`python server_fastapi.py`するとAPIサーバーが起動します。
|
143 |
+
API仕様は起動後に`/docs`にて確認ください。
|
144 |
+
|
145 |
+
- 入力文字数はデフォルトで100文字が上限となっています。これは`config.yml`の`server.limit`で変更できます。
|
146 |
+
- デフォルトではCORS設定を全てのドメインで許可しています。できる限り、`config.yml`の`server.origins`の値を変更し、信頼できるドメインに制限ください(キーを消せばCORS設定を無効にできます)。
|
147 |
+
|
148 |
+
また音声合成エディターのAPIサーバーは`python server_editor.py`で起動します。があまりまだ整備をしていません。[エディターのリポジトリ](https://github.com/litagin02/Style-Bert-VITS2-Editor)から必要な最低限のAPIしか現在は実装していません。
|
149 |
+
|
150 |
+
音声合成エディターのウェブデプロイについては[このDockerfile](Dockerfile.deploy)を参考にしてください。
|
151 |
+
|
152 |
+
### マージ
|
153 |
+
|
154 |
+
2つのモデルを、「声質」「声の高さ」「感情表現」「テンポ」の4点で混ぜ合わせて、新しいモデルを作ることが出来ます。
|
155 |
+
`App.bat`をダブルクリックか`python app.py`して開くWebUIの「マージ」タブから、2つのモデルを選択してマージすることができます。
|
156 |
+
|
157 |
+
### 自然性評価
|
158 |
+
|
159 |
+
学習結果のうちどのステップ数がいいかの「一つの」指標として、[SpeechMOS](https://github.com/tarepan/SpeechMOS) を使うスクリプトを用意しています:
|
160 |
+
```bash
|
161 |
+
python speech_mos.py -m <model_name>
|
162 |
+
```
|
163 |
+
ステップごとの自然性評価が表示され、`mos_results`フォルダの`mos_{model_name}.csv`と`mos_{model_name}.png`に結果が保存される。読み上げさせたい文章を変えたかったら中のファイルを弄って各自調整してください。またあくまでアクセントや感情表現や抑揚を全く考えない基準での評価で、目安のひとつなので、実際に読み上げさせて選別するのが一番だと思います。
|
164 |
+
|
165 |
+
## Bert-VITS2との関係
|
166 |
+
|
167 |
+
基本的にはBert-VITS2のモデル構造を少し改造しただけです。[旧事前学習モデル](https://huggingface.co/litagin/Style-Bert-VITS2-1.0-base)も[JP-Extraの事前学習モデル](https://huggingface.co/litagin/Style-Bert-VITS2-2.0-base-JP-Extra)も、実質Bert-VITS2 v2.1 or JP-Extraと同じものを使用しています(不要な重みを削ってsafetensorsに変換したもの)。
|
168 |
+
|
169 |
+
具体的には以下の点が異なります。
|
170 |
+
|
171 |
+
- [EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2)のように、PythonやGitを知らない人でも簡単に使える。
|
172 |
+
- 感情埋め込みのモデルを変更(256次元の[wespeaker-voxceleb-resnet34-LM](https://huggingface.co/pyannote/wespeaker-voxceleb-resnet34-LM)へ、感情埋め込みというよりは話者識別のための埋め込み)
|
173 |
+
- 感情埋め込みもベクトル量子化を取り払い、単なる全結合層に。
|
174 |
+
- スタイルベクトルファイル`style_vectors.npy`を作ることで、そのスタイルを使って効果の強さも連続的に指定しつつ音声を生成することができる。
|
175 |
+
- 各種WebUIを作成
|
176 |
+
- bf16での学習のサポート
|
177 |
+
- safetensors形式のサポート、デフォルトでsafetensorsを使用するように
|
178 |
+
- その他軽微なbugfixやリファクタリング
|
179 |
+
|
180 |
+
|
181 |
+
## References
|
182 |
+
In addition to the original reference (written below), I used the following repositories:
|
183 |
+
- [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)
|
184 |
+
- [EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2)
|
185 |
+
|
186 |
+
[The pretrained model](https://huggingface.co/litagin/Style-Bert-VITS2-1.0-base) and [JP-Extra version](https://huggingface.co/litagin/Style-Bert-VITS2-2.0-base-JP-Extra) is essentially taken from [the original base model of Bert-VITS2 v2.1](https://huggingface.co/Garydesu/bert-vits2_base_model-2.1) and [JP-Extra pretrained model of Bert-VITS2](https://huggingface.co/Stardust-minus/Bert-VITS2-Japanese-Extra), so all the credits go to the original author ([Fish Audio](https://github.com/fishaudio)):
|
187 |
+
|
188 |
+
|
189 |
+
In addition, [text/user_dict/](text/user_dict) module is based on the following repositories:
|
190 |
+
- [voicevox_engine](https://github.com/VOICEVOX/voicevox_engine)
|
191 |
+
and the license of this module is LGPL v3.
|
192 |
+
|
193 |
+
## LICENSE
|
194 |
+
|
195 |
+
This repository is licensed under the GNU Affero General Public License v3.0, the same as the original Bert-VITS2 repository. For more details, see [LICENSE](LICENSE).
|
196 |
+
|
197 |
+
In addition, [text/user_dict/](text/user_dict) module is licensed under the GNU Lesser General Public License v3.0, inherited from the original VOICEVOX engine repository. For more details, see [LGPL_LICENSE](LGPL_LICENSE).
|
198 |
+
|
199 |
+
|
200 |
+
|
201 |
+
Below is the original README.md.
|
202 |
+
---
|
203 |
+
|
204 |
+
<div align="center">
|
205 |
+
|
206 |
+
<img alt="LOGO" src="https://cdn.jsdelivr.net/gh/fishaudio/fish-diffusion@main/images/logo_512x512.png" width="256" height="256" />
|
207 |
+
|
208 |
+
# Bert-VITS2
|
209 |
+
|
210 |
+
VITS2 Backbone with multilingual bert
|
211 |
+
|
212 |
+
For quick guide, please refer to `webui_preprocess.py`.
|
213 |
+
|
214 |
+
简易教程请参见 `webui_preprocess.py`。
|
215 |
+
|
216 |
+
## 请注意,本项目核心思路来源于[anyvoiceai/MassTTS](https://github.com/anyvoiceai/MassTTS) 一个非常好的tts项目
|
217 |
+
## MassTTS的演示demo为[ai版峰哥锐评峰哥本人,并找回了在金三角失落的腰子](https://www.bilibili.com/video/BV1w24y1c7z9)
|
218 |
+
|
219 |
+
[//]: # (## 本项目与[PlayVoice/vits_chinese](https://github.com/PlayVoice/vits_chinese) 没有任何关系)
|
220 |
+
|
221 |
+
[//]: # ()
|
222 |
+
[//]: # (本仓库来源于之前朋友分享了ai峰哥的视频,本人被其中的效果惊艳,在自己尝试MassTTS以后发现fs在音质方面与vits有一定差距,并且training的pipeline比vits更复杂,因此按照其思路将bert)
|
223 |
+
|
224 |
+
## 成熟的旅行者/开拓者/舰长/博士/sensei/猎魔人/喵喵露/V应当参阅代码自己学习如何训练。
|
225 |
+
|
226 |
+
### 严禁将此项目用于一切违反《中华人民共和国宪法》,《中华人民共和国刑法》,《中华人民共和国治安管理处罚法》和《中华人民共和国民法典》之用途。
|
227 |
+
### 严禁用于任何政治相关用途。
|
228 |
+
#### Video:https://www.bilibili.com/video/BV1hp4y1K78E
|
229 |
+
#### Demo:https://www.bilibili.com/video/BV1TF411k78w
|
230 |
+
#### QQ Group:815818430
|
231 |
+
## References
|
232 |
+
+ [anyvoiceai/MassTTS](https://github.com/anyvoiceai/MassTTS)
|
233 |
+
+ [jaywalnut310/vits](https://github.com/jaywalnut310/vits)
|
234 |
+
+ [p0p4k/vits2_pytorch](https://github.com/p0p4k/vits2_pytorch)
|
235 |
+
+ [svc-develop-team/so-vits-svc](https://github.com/svc-develop-team/so-vits-svc)
|
236 |
+
+ [PaddlePaddle/PaddleSpeech](https://github.com/PaddlePaddle/PaddleSpeech)
|
237 |
+
+ [emotional-vits](https://github.com/innnky/emotional-vits)
|
238 |
+
+ [fish-speech](https://github.com/fishaudio/fish-speech)
|
239 |
+
+ [Bert-VITS2-UI](https://github.com/jiangyuxiaoxiao/Bert-VITS2-UI)
|
240 |
+
## 感谢所有贡献者作出的努力
|
241 |
+
<a href="https://github.com/fishaudio/Bert-VITS2/graphs/contributors" target="_blank">
|
242 |
+
<img src="https://contrib.rocks/image?repo=fishaudio/Bert-VITS2"/>
|
243 |
+
</a>
|
244 |
|
245 |
+
[//]: # (# 本项目所有代码引用均已写明,bert部分代码思路来源于[AI峰哥](https://www.bilibili.com/video/BV1w24y1c7z9),与[vits_chinese](https://github.com/PlayVoice/vits_chinese)无任何关系。欢迎各位查阅代码。同时,我们也对该开发者的[碰瓷,乃至开盒开发者的行为](https://www.bilibili.com/read/cv27101514/)表示强烈谴责。)
|
Server.bat
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
chcp 65001 > NUL
|
2 |
+
@echo off
|
3 |
+
|
4 |
+
pushd %~dp0
|
5 |
+
echo Running server_fastapi.py
|
6 |
+
venv\Scripts\python server_fastapi.py
|
7 |
+
|
8 |
+
if %errorlevel% neq 0 ( pause & popd & exit /b %errorlevel% )
|
9 |
+
|
10 |
+
popd
|
11 |
+
pause
|
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import torch
|
6 |
+
import yaml
|
7 |
+
|
8 |
+
from gradio_tabs.dataset import create_dataset_app
|
9 |
+
from gradio_tabs.inference import create_inference_app
|
10 |
+
from gradio_tabs.merge import create_merge_app
|
11 |
+
from gradio_tabs.style_vectors import create_style_vectors_app
|
12 |
+
from gradio_tabs.train import create_train_app
|
13 |
+
from style_bert_vits2.constants import GRADIO_THEME, VERSION
|
14 |
+
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker
|
15 |
+
from style_bert_vits2.nlp.japanese.user_dict import update_dict
|
16 |
+
from style_bert_vits2.tts_model import TTSModelHolder
|
17 |
+
|
18 |
+
|
19 |
+
# このプロセスからはワーカーを起動して辞書を使いたいので、ここで初期化
|
20 |
+
pyopenjtalk_worker.initialize_worker()
|
21 |
+
|
22 |
+
# dict_data/ 以下の辞書データを pyopenjtalk に適用
|
23 |
+
update_dict()
|
24 |
+
|
25 |
+
# Get path settings
|
26 |
+
with Path("configs/paths.yml").open("r", encoding="utf-8") as f:
|
27 |
+
path_config: dict[str, str] = yaml.safe_load(f.read())
|
28 |
+
# dataset_root = path_config["dataset_root"]
|
29 |
+
assets_root = path_config["assets_root"]
|
30 |
+
|
31 |
+
parser = argparse.ArgumentParser()
|
32 |
+
parser.add_argument("--device", type=str, default="cuda")
|
33 |
+
parser.add_argument("--host", type=str, default="127.0.0.1")
|
34 |
+
parser.add_argument("--port", type=int, default=None)
|
35 |
+
parser.add_argument("--no_autolaunch", action="store_true")
|
36 |
+
parser.add_argument("--share", action="store_true")
|
37 |
+
|
38 |
+
args = parser.parse_args()
|
39 |
+
device = args.device
|
40 |
+
if device == "cuda" and not torch.cuda.is_available():
|
41 |
+
device = "cpu"
|
42 |
+
|
43 |
+
model_holder = TTSModelHolder(Path(assets_root), device)
|
44 |
+
|
45 |
+
with gr.Blocks(theme=GRADIO_THEME) as app:
|
46 |
+
gr.Markdown(f"# Style-Bert-VITS2 WebUI (version {VERSION})")
|
47 |
+
with gr.Tabs():
|
48 |
+
with gr.Tab("音声合成"):
|
49 |
+
create_inference_app(model_holder=model_holder)
|
50 |
+
with gr.Tab("データセット作成"):
|
51 |
+
create_dataset_app()
|
52 |
+
with gr.Tab("学習"):
|
53 |
+
create_train_app()
|
54 |
+
with gr.Tab("スタイル作成"):
|
55 |
+
create_style_vectors_app()
|
56 |
+
with gr.Tab("マージ"):
|
57 |
+
create_merge_app(model_holder=model_holder)
|
58 |
+
|
59 |
+
|
60 |
+
app.launch(
|
61 |
+
server_name=args.host,
|
62 |
+
server_port=args.port,
|
63 |
+
inbrowser=not args.no_autolaunch,
|
64 |
+
share=args.share,
|
65 |
+
)
|
bert/bert_models.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"deberta-v2-large-japanese-char-wwm": {
|
3 |
+
"repo_id": "ku-nlp/deberta-v2-large-japanese-char-wwm",
|
4 |
+
"files": ["pytorch_model.bin"]
|
5 |
+
},
|
6 |
+
"chinese-roberta-wwm-ext-large": {
|
7 |
+
"repo_id": "hfl/chinese-roberta-wwm-ext-large",
|
8 |
+
"files": ["pytorch_model.bin"]
|
9 |
+
},
|
10 |
+
"deberta-v3-large": {
|
11 |
+
"repo_id": "microsoft/deberta-v3-large",
|
12 |
+
"files": ["spm.model", "pytorch_model.bin"]
|
13 |
+
}
|
14 |
+
}
|
bert/chinese-roberta-wwm-ext-large/.gitattributes
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
bert/chinese-roberta-wwm-ext-large/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
tags:
|
5 |
+
- bert
|
6 |
+
license: "apache-2.0"
|
7 |
+
---
|
8 |
+
|
9 |
+
# Please use 'Bert' related functions to load this model!
|
10 |
+
|
11 |
+
## Chinese BERT with Whole Word Masking
|
12 |
+
For further accelerating Chinese natural language processing, we provide **Chinese pre-trained BERT with Whole Word Masking**.
|
13 |
+
|
14 |
+
**[Pre-Training with Whole Word Masking for Chinese BERT](https://arxiv.org/abs/1906.08101)**
|
15 |
+
Yiming Cui, Wanxiang Che, Ting Liu, Bing Qin, Ziqing Yang, Shijin Wang, Guoping Hu
|
16 |
+
|
17 |
+
This repository is developed based on:https://github.com/google-research/bert
|
18 |
+
|
19 |
+
You may also interested in,
|
20 |
+
- Chinese BERT series: https://github.com/ymcui/Chinese-BERT-wwm
|
21 |
+
- Chinese MacBERT: https://github.com/ymcui/MacBERT
|
22 |
+
- Chinese ELECTRA: https://github.com/ymcui/Chinese-ELECTRA
|
23 |
+
- Chinese XLNet: https://github.com/ymcui/Chinese-XLNet
|
24 |
+
- Knowledge Distillation Toolkit - TextBrewer: https://github.com/airaria/TextBrewer
|
25 |
+
|
26 |
+
More resources by HFL: https://github.com/ymcui/HFL-Anthology
|
27 |
+
|
28 |
+
## Citation
|
29 |
+
If you find the technical report or resource is useful, please cite the following technical report in your paper.
|
30 |
+
- Primary: https://arxiv.org/abs/2004.13922
|
31 |
+
```
|
32 |
+
@inproceedings{cui-etal-2020-revisiting,
|
33 |
+
title = "Revisiting Pre-Trained Models for {C}hinese Natural Language Processing",
|
34 |
+
author = "Cui, Yiming and
|
35 |
+
Che, Wanxiang and
|
36 |
+
Liu, Ting and
|
37 |
+
Qin, Bing and
|
38 |
+
Wang, Shijin and
|
39 |
+
Hu, Guoping",
|
40 |
+
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings",
|
41 |
+
month = nov,
|
42 |
+
year = "2020",
|
43 |
+
address = "Online",
|
44 |
+
publisher = "Association for Computational Linguistics",
|
45 |
+
url = "https://www.aclweb.org/anthology/2020.findings-emnlp.58",
|
46 |
+
pages = "657--668",
|
47 |
+
}
|
48 |
+
```
|
49 |
+
- Secondary: https://arxiv.org/abs/1906.08101
|
50 |
+
```
|
51 |
+
@article{chinese-bert-wwm,
|
52 |
+
title={Pre-Training with Whole Word Masking for Chinese BERT},
|
53 |
+
author={Cui, Yiming and Che, Wanxiang and Liu, Ting and Qin, Bing and Yang, Ziqing and Wang, Shijin and Hu, Guoping},
|
54 |
+
journal={arXiv preprint arXiv:1906.08101},
|
55 |
+
year={2019}
|
56 |
+
}
|
57 |
+
```
|
bert/chinese-roberta-wwm-ext-large/added_tokens.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{}
|
bert/chinese-roberta-wwm-ext-large/config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"BertForMaskedLM"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"bos_token_id": 0,
|
7 |
+
"directionality": "bidi",
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 1024,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 4096,
|
14 |
+
"layer_norm_eps": 1e-12,
|
15 |
+
"max_position_embeddings": 512,
|
16 |
+
"model_type": "bert",
|
17 |
+
"num_attention_heads": 16,
|
18 |
+
"num_hidden_layers": 24,
|
19 |
+
"output_past": true,
|
20 |
+
"pad_token_id": 0,
|
21 |
+
"pooler_fc_size": 768,
|
22 |
+
"pooler_num_attention_heads": 12,
|
23 |
+
"pooler_num_fc_layers": 3,
|
24 |
+
"pooler_size_per_head": 128,
|
25 |
+
"pooler_type": "first_token_transform",
|
26 |
+
"type_vocab_size": 2,
|
27 |
+
"vocab_size": 21128
|
28 |
+
}
|
bert/chinese-roberta-wwm-ext-large/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
bert/chinese-roberta-wwm-ext-large/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
bert/chinese-roberta-wwm-ext-large/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"init_inputs": []}
|
bert/chinese-roberta-wwm-ext-large/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
bert/deberta-v2-large-japanese-char-wwm/.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
bert/deberta-v2-large-japanese-char-wwm/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: ja
|
3 |
+
license: cc-by-sa-4.0
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- deberta
|
7 |
+
- deberta-v2
|
8 |
+
- fill-mask
|
9 |
+
- character
|
10 |
+
- wwm
|
11 |
+
datasets:
|
12 |
+
- wikipedia
|
13 |
+
- cc100
|
14 |
+
- oscar
|
15 |
+
metrics:
|
16 |
+
- accuracy
|
17 |
+
mask_token: "[MASK]"
|
18 |
+
widget:
|
19 |
+
- text: "京都大学で自然言語処理を[MASK][MASK]する。"
|
20 |
+
---
|
21 |
+
|
22 |
+
# Model Card for Japanese character-level DeBERTa V2 large
|
23 |
+
|
24 |
+
## Model description
|
25 |
+
|
26 |
+
This is a Japanese DeBERTa V2 large model pre-trained on Japanese Wikipedia, the Japanese portion of CC-100, and the Japanese portion of OSCAR.
|
27 |
+
This model is trained with character-level tokenization and whole word masking.
|
28 |
+
|
29 |
+
## How to use
|
30 |
+
|
31 |
+
You can use this model for masked language modeling as follows:
|
32 |
+
|
33 |
+
```python
|
34 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained('ku-nlp/deberta-v2-large-japanese-char-wwm')
|
36 |
+
model = AutoModelForMaskedLM.from_pretrained('ku-nlp/deberta-v2-large-japanese-char-wwm')
|
37 |
+
|
38 |
+
sentence = '京都大学で自然言語処理を[MASK][MASK]する。'
|
39 |
+
encoding = tokenizer(sentence, return_tensors='pt')
|
40 |
+
...
|
41 |
+
```
|
42 |
+
|
43 |
+
You can also fine-tune this model on downstream tasks.
|
44 |
+
|
45 |
+
## Tokenization
|
46 |
+
|
47 |
+
There is no need to tokenize texts in advance, and you can give raw texts to the tokenizer.
|
48 |
+
The texts are tokenized into character-level tokens by [sentencepiece](https://github.com/google/sentencepiece).
|
49 |
+
|
50 |
+
## Training data
|
51 |
+
|
52 |
+
We used the following corpora for pre-training:
|
53 |
+
|
54 |
+
- Japanese Wikipedia (as of 20221020, 3.2GB, 27M sentences, 1.3M documents)
|
55 |
+
- Japanese portion of CC-100 (85GB, 619M sentences, 66M documents)
|
56 |
+
- Japanese portion of OSCAR (54GB, 326M sentences, 25M documents)
|
57 |
+
|
58 |
+
Note that we filtered out documents annotated with "header", "footer", or "noisy" tags in OSCAR.
|
59 |
+
Also note that Japanese Wikipedia was duplicated 10 times to make the total size of the corpus comparable to that of CC-100 and OSCAR. As a result, the total size of the training data is 171GB.
|
60 |
+
|
61 |
+
## Training procedure
|
62 |
+
|
63 |
+
We first segmented texts in the corpora into words using [Juman++ 2.0.0-rc3](https://github.com/ku-nlp/jumanpp/releases/tag/v2.0.0-rc3) for whole word masking.
|
64 |
+
Then, we built a sentencepiece model with 22,012 tokens including all characters that appear in the training corpus.
|
65 |
+
|
66 |
+
We tokenized raw corpora into character-level subwords using the sentencepiece model and trained the Japanese DeBERTa model using [transformers](https://github.com/huggingface/transformers) library.
|
67 |
+
The training took 26 days using 16 NVIDIA A100-SXM4-40GB GPUs.
|
68 |
+
|
69 |
+
The following hyperparameters were used during pre-training:
|
70 |
+
|
71 |
+
- learning_rate: 1e-4
|
72 |
+
- per_device_train_batch_size: 26
|
73 |
+
- distributed_type: multi-GPU
|
74 |
+
- num_devices: 16
|
75 |
+
- gradient_accumulation_steps: 8
|
76 |
+
- total_train_batch_size: 3,328
|
77 |
+
- max_seq_length: 512
|
78 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-06
|
79 |
+
- lr_scheduler_type: linear schedule with warmup (lr = 0 at 300k steps)
|
80 |
+
- training_steps: 260,000
|
81 |
+
- warmup_steps: 10,000
|
82 |
+
|
83 |
+
The accuracy of the trained model on the masked language modeling task was 0.795.
|
84 |
+
The evaluation set consists of 5,000 randomly sampled documents from each of the training corpora.
|
85 |
+
|
86 |
+
## Acknowledgments
|
87 |
+
|
88 |
+
This work was supported by Joint Usage/Research Center for Interdisciplinary Large-scale Information Infrastructures (JHPCN) through General Collaboration Project no. jh221004, "Developing a Platform for Constructing and Sharing of Large-Scale Japanese Language Models".
|
89 |
+
For training models, we used the mdx: a platform for the data-driven future.
|
bert/deberta-v2-large-japanese-char-wwm/config.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"DebertaV2ForMaskedLM"
|
4 |
+
],
|
5 |
+
"attention_head_size": 64,
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"conv_act": "gelu",
|
8 |
+
"conv_kernel_size": 3,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 1024,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 4096,
|
14 |
+
"layer_norm_eps": 1e-07,
|
15 |
+
"max_position_embeddings": 512,
|
16 |
+
"max_relative_positions": -1,
|
17 |
+
"model_type": "deberta-v2",
|
18 |
+
"norm_rel_ebd": "layer_norm",
|
19 |
+
"num_attention_heads": 16,
|
20 |
+
"num_hidden_layers": 24,
|
21 |
+
"pad_token_id": 0,
|
22 |
+
"pooler_dropout": 0,
|
23 |
+
"pooler_hidden_act": "gelu",
|
24 |
+
"pooler_hidden_size": 1024,
|
25 |
+
"pos_att_type": [
|
26 |
+
"p2c",
|
27 |
+
"c2p"
|
28 |
+
],
|
29 |
+
"position_biased_input": false,
|
30 |
+
"position_buckets": 256,
|
31 |
+
"relative_attention": true,
|
32 |
+
"share_att_key": true,
|
33 |
+
"torch_dtype": "float16",
|
34 |
+
"transformers_version": "4.25.1",
|
35 |
+
"type_vocab_size": 0,
|
36 |
+
"vocab_size": 22012
|
37 |
+
}
|
bert/deberta-v2-large-japanese-char-wwm/special_tokens_map.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": "[CLS]",
|
3 |
+
"mask_token": "[MASK]",
|
4 |
+
"pad_token": "[PAD]",
|
5 |
+
"sep_token": "[SEP]",
|
6 |
+
"unk_token": "[UNK]"
|
7 |
+
}
|
bert/deberta-v2-large-japanese-char-wwm/tokenizer_config.json
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": "[CLS]",
|
3 |
+
"do_lower_case": false,
|
4 |
+
"do_subword_tokenize": true,
|
5 |
+
"do_word_tokenize": true,
|
6 |
+
"jumanpp_kwargs": null,
|
7 |
+
"mask_token": "[MASK]",
|
8 |
+
"mecab_kwargs": null,
|
9 |
+
"model_max_length": 1000000000000000019884624838656,
|
10 |
+
"never_split": null,
|
11 |
+
"pad_token": "[PAD]",
|
12 |
+
"sep_token": "[SEP]",
|
13 |
+
"special_tokens_map_file": null,
|
14 |
+
"subword_tokenizer_type": "character",
|
15 |
+
"sudachi_kwargs": null,
|
16 |
+
"tokenizer_class": "BertJapaneseTokenizer",
|
17 |
+
"unk_token": "[UNK]",
|
18 |
+
"word_tokenizer_type": "basic"
|
19 |
+
}
|
bert/deberta-v2-large-japanese-char-wwm/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
bert/deberta-v3-large/.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
bert/deberta-v3-large/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
tags:
|
4 |
+
- deberta
|
5 |
+
- deberta-v3
|
6 |
+
- fill-mask
|
7 |
+
thumbnail: https://huggingface.co/front/thumbnails/microsoft.png
|
8 |
+
license: mit
|
9 |
+
---
|
10 |
+
|
11 |
+
## DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing
|
12 |
+
|
13 |
+
[DeBERTa](https://arxiv.org/abs/2006.03654) improves the BERT and RoBERTa models using disentangled attention and enhanced mask decoder. With those two improvements, DeBERTa out perform RoBERTa on a majority of NLU tasks with 80GB training data.
|
14 |
+
|
15 |
+
In [DeBERTa V3](https://arxiv.org/abs/2111.09543), we further improved the efficiency of DeBERTa using ELECTRA-Style pre-training with Gradient Disentangled Embedding Sharing. Compared to DeBERTa, our V3 version significantly improves the model performance on downstream tasks. You can find more technique details about the new model from our [paper](https://arxiv.org/abs/2111.09543).
|
16 |
+
|
17 |
+
Please check the [official repository](https://github.com/microsoft/DeBERTa) for more implementation details and updates.
|
18 |
+
|
19 |
+
The DeBERTa V3 large model comes with 24 layers and a hidden size of 1024. It has 304M backbone parameters with a vocabulary containing 128K tokens which introduces 131M parameters in the Embedding layer. This model was trained using the 160GB data as DeBERTa V2.
|
20 |
+
|
21 |
+
|
22 |
+
#### Fine-tuning on NLU tasks
|
23 |
+
|
24 |
+
We present the dev results on SQuAD 2.0 and MNLI tasks.
|
25 |
+
|
26 |
+
| Model |Vocabulary(K)|Backbone #Params(M)| SQuAD 2.0(F1/EM) | MNLI-m/mm(ACC)|
|
27 |
+
|-------------------|----------|-------------------|-----------|----------|
|
28 |
+
| RoBERTa-large |50 |304 | 89.4/86.5 | 90.2 |
|
29 |
+
| XLNet-large |32 |- | 90.6/87.9 | 90.8 |
|
30 |
+
| DeBERTa-large |50 |- | 90.7/88.0 | 91.3 |
|
31 |
+
| **DeBERTa-v3-large**|128|304 | **91.5/89.0**| **91.8/91.9**|
|
32 |
+
|
33 |
+
|
34 |
+
#### Fine-tuning with HF transformers
|
35 |
+
|
36 |
+
```bash
|
37 |
+
#!/bin/bash
|
38 |
+
|
39 |
+
cd transformers/examples/pytorch/text-classification/
|
40 |
+
|
41 |
+
pip install datasets
|
42 |
+
export TASK_NAME=mnli
|
43 |
+
|
44 |
+
output_dir="ds_results"
|
45 |
+
|
46 |
+
num_gpus=8
|
47 |
+
|
48 |
+
batch_size=8
|
49 |
+
|
50 |
+
python -m torch.distributed.launch --nproc_per_node=${num_gpus} \
|
51 |
+
run_glue.py \
|
52 |
+
--model_name_or_path microsoft/deberta-v3-large \
|
53 |
+
--task_name $TASK_NAME \
|
54 |
+
--do_train \
|
55 |
+
--do_eval \
|
56 |
+
--evaluation_strategy steps \
|
57 |
+
--max_seq_length 256 \
|
58 |
+
--warmup_steps 50 \
|
59 |
+
--per_device_train_batch_size ${batch_size} \
|
60 |
+
--learning_rate 6e-6 \
|
61 |
+
--num_train_epochs 2 \
|
62 |
+
--output_dir $output_dir \
|
63 |
+
--overwrite_output_dir \
|
64 |
+
--logging_steps 1000 \
|
65 |
+
--logging_dir $output_dir
|
66 |
+
|
67 |
+
```
|
68 |
+
|
69 |
+
### Citation
|
70 |
+
|
71 |
+
If you find DeBERTa useful for your work, please cite the following papers:
|
72 |
+
|
73 |
+
``` latex
|
74 |
+
@misc{he2021debertav3,
|
75 |
+
title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
|
76 |
+
author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
|
77 |
+
year={2021},
|
78 |
+
eprint={2111.09543},
|
79 |
+
archivePrefix={arXiv},
|
80 |
+
primaryClass={cs.CL}
|
81 |
+
}
|
82 |
+
```
|
83 |
+
|
84 |
+
``` latex
|
85 |
+
@inproceedings{
|
86 |
+
he2021deberta,
|
87 |
+
title={DEBERTA: DECODING-ENHANCED BERT WITH DISENTANGLED ATTENTION},
|
88 |
+
author={Pengcheng He and Xiaodong Liu and Jianfeng Gao and Weizhu Chen},
|
89 |
+
booktitle={International Conference on Learning Representations},
|
90 |
+
year={2021},
|
91 |
+
url={https://openreview.net/forum?id=XPZIaotutsD}
|
92 |
+
}
|
93 |
+
```
|
bert/deberta-v3-large/config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_type": "deberta-v2",
|
3 |
+
"attention_probs_dropout_prob": 0.1,
|
4 |
+
"hidden_act": "gelu",
|
5 |
+
"hidden_dropout_prob": 0.1,
|
6 |
+
"hidden_size": 1024,
|
7 |
+
"initializer_range": 0.02,
|
8 |
+
"intermediate_size": 4096,
|
9 |
+
"max_position_embeddings": 512,
|
10 |
+
"relative_attention": true,
|
11 |
+
"position_buckets": 256,
|
12 |
+
"norm_rel_ebd": "layer_norm",
|
13 |
+
"share_att_key": true,
|
14 |
+
"pos_att_type": "p2c|c2p",
|
15 |
+
"layer_norm_eps": 1e-7,
|
16 |
+
"max_relative_positions": -1,
|
17 |
+
"position_biased_input": false,
|
18 |
+
"num_attention_heads": 16,
|
19 |
+
"num_hidden_layers": 24,
|
20 |
+
"type_vocab_size": 0,
|
21 |
+
"vocab_size": 128100
|
22 |
+
}
|
bert/deberta-v3-large/generator_config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_type": "deberta-v2",
|
3 |
+
"attention_probs_dropout_prob": 0.1,
|
4 |
+
"hidden_act": "gelu",
|
5 |
+
"hidden_dropout_prob": 0.1,
|
6 |
+
"hidden_size": 1024,
|
7 |
+
"initializer_range": 0.02,
|
8 |
+
"intermediate_size": 4096,
|
9 |
+
"max_position_embeddings": 512,
|
10 |
+
"relative_attention": true,
|
11 |
+
"position_buckets": 256,
|
12 |
+
"norm_rel_ebd": "layer_norm",
|
13 |
+
"share_att_key": true,
|
14 |
+
"pos_att_type": "p2c|c2p",
|
15 |
+
"layer_norm_eps": 1e-7,
|
16 |
+
"max_relative_positions": -1,
|
17 |
+
"position_biased_input": false,
|
18 |
+
"num_attention_heads": 16,
|
19 |
+
"num_hidden_layers": 12,
|
20 |
+
"type_vocab_size": 0,
|
21 |
+
"vocab_size": 128100
|
22 |
+
}
|
bert/deberta-v3-large/tokenizer_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_lower_case": false,
|
3 |
+
"vocab_type": "spm"
|
4 |
+
}
|
bert_gen.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
from concurrent.futures import ThreadPoolExecutor
|
3 |
+
|
4 |
+
import torch
|
5 |
+
import torch.multiprocessing as mp
|
6 |
+
from tqdm import tqdm
|
7 |
+
|
8 |
+
from config import config
|
9 |
+
from style_bert_vits2.constants import Languages
|
10 |
+
from style_bert_vits2.logging import logger
|
11 |
+
from style_bert_vits2.models import commons
|
12 |
+
from style_bert_vits2.models.hyper_parameters import HyperParameters
|
13 |
+
from style_bert_vits2.nlp import (
|
14 |
+
bert_models,
|
15 |
+
cleaned_text_to_sequence,
|
16 |
+
extract_bert_feature,
|
17 |
+
)
|
18 |
+
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker
|
19 |
+
from style_bert_vits2.nlp.japanese.user_dict import update_dict
|
20 |
+
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT
|
21 |
+
|
22 |
+
|
23 |
+
# このプロセスからはワーカーを起動して辞書を使いたいので、ここで初期化
|
24 |
+
pyopenjtalk_worker.initialize_worker()
|
25 |
+
|
26 |
+
# dict_data/ 以下の辞書データを pyopenjtalk に適用
|
27 |
+
update_dict()
|
28 |
+
|
29 |
+
|
30 |
+
def process_line(x: tuple[str, bool]):
|
31 |
+
line, add_blank = x
|
32 |
+
device = config.bert_gen_config.device
|
33 |
+
if config.bert_gen_config.use_multi_device:
|
34 |
+
rank = mp.current_process()._identity
|
35 |
+
rank = rank[0] if len(rank) > 0 else 0
|
36 |
+
if torch.cuda.is_available():
|
37 |
+
gpu_id = rank % torch.cuda.device_count()
|
38 |
+
device = f"cuda:{gpu_id}"
|
39 |
+
else:
|
40 |
+
device = "cpu"
|
41 |
+
wav_path, _, language_str, text, phones, tone, word2ph = line.strip().split("|")
|
42 |
+
phone = phones.split(" ")
|
43 |
+
tone = [int(i) for i in tone.split(" ")]
|
44 |
+
word2ph = [int(i) for i in word2ph.split(" ")]
|
45 |
+
word2ph = [i for i in word2ph]
|
46 |
+
phone, tone, language = cleaned_text_to_sequence(
|
47 |
+
phone, tone, Languages[language_str]
|
48 |
+
)
|
49 |
+
|
50 |
+
if add_blank:
|
51 |
+
phone = commons.intersperse(phone, 0)
|
52 |
+
tone = commons.intersperse(tone, 0)
|
53 |
+
language = commons.intersperse(language, 0)
|
54 |
+
for i in range(len(word2ph)):
|
55 |
+
word2ph[i] = word2ph[i] * 2
|
56 |
+
word2ph[0] += 1
|
57 |
+
|
58 |
+
bert_path = wav_path.replace(".WAV", ".wav").replace(".wav", ".bert.pt")
|
59 |
+
|
60 |
+
try:
|
61 |
+
bert = torch.load(bert_path)
|
62 |
+
assert bert.shape[-1] == len(phone)
|
63 |
+
except Exception:
|
64 |
+
bert = extract_bert_feature(text, word2ph, language_str, device)
|
65 |
+
assert bert.shape[-1] == len(phone)
|
66 |
+
torch.save(bert, bert_path)
|
67 |
+
|
68 |
+
|
69 |
+
preprocess_text_config = config.preprocess_text_config
|
70 |
+
|
71 |
+
if __name__ == "__main__":
|
72 |
+
parser = argparse.ArgumentParser()
|
73 |
+
parser.add_argument(
|
74 |
+
"-c", "--config", type=str, default=config.bert_gen_config.config_path
|
75 |
+
)
|
76 |
+
args, _ = parser.parse_known_args()
|
77 |
+
config_path = args.config
|
78 |
+
hps = HyperParameters.load_from_json(config_path)
|
79 |
+
lines: list[str] = []
|
80 |
+
with open(hps.data.training_files, "r", encoding="utf-8") as f:
|
81 |
+
lines.extend(f.readlines())
|
82 |
+
|
83 |
+
with open(hps.data.validation_files, "r", encoding="utf-8") as f:
|
84 |
+
lines.extend(f.readlines())
|
85 |
+
add_blank = [hps.data.add_blank] * len(lines)
|
86 |
+
|
87 |
+
if len(lines) != 0:
|
88 |
+
# pyopenjtalkの別ワーカー化により、並列処理でエラーがでる模様なので、一旦シングルスレッド強制にする
|
89 |
+
num_processes = 1
|
90 |
+
with ThreadPoolExecutor(max_workers=num_processes) as executor:
|
91 |
+
_ = list(
|
92 |
+
tqdm(
|
93 |
+
executor.map(process_line, zip(lines, add_blank)),
|
94 |
+
total=len(lines),
|
95 |
+
file=SAFE_STDOUT,
|
96 |
+
)
|
97 |
+
)
|
98 |
+
|
99 |
+
logger.info(f"bert.pt is generated! total: {len(lines)} bert.pt files.")
|
clustering.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
colab.ipynb
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Style-Bert-VITS2 (ver 2.4.1) のGoogle Colabでの学習\n",
|
8 |
+
"\n",
|
9 |
+
"Google Colab上でStyle-Bert-VITS2の学習を行うことができます。\n",
|
10 |
+
"\n",
|
11 |
+
"このnotebookでは、通常使用ではあなたのGoogle Driveにフォルダ`Style-Bert-VITS2`を作り、その内部での作業を行います。他のフォルダには触れません。\n",
|
12 |
+
"Google Driveを使わない場合は、初期設定のところで適切なパスを指定してください。\n",
|
13 |
+
"\n",
|
14 |
+
"## 流れ\n",
|
15 |
+
"\n",
|
16 |
+
"### 学習を最初からやりたいとき\n",
|
17 |
+
"上から順に実行していけばいいです。音声合成に必要なファイルはGoogle Driveの`Style-Bert-VITS2/model_assets/`に保存されます。また、途中経過も`Style-Bert-VITS2/Data/`に保存されるので、学習を中断したり、途中から再開することもできます。\n",
|
18 |
+
"\n",
|
19 |
+
"### 学習を途中から再開したいとき\n",
|
20 |
+
"0と1を行い、3の前処理は飛ばして、4から始めてください。スタイル分け5は、学習が終わったら必要なら行ってください。\n"
|
21 |
+
]
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"cell_type": "markdown",
|
25 |
+
"metadata": {},
|
26 |
+
"source": [
|
27 |
+
"## 0. 環境構築\n",
|
28 |
+
"\n",
|
29 |
+
"Style-Bert-VITS2の環境をcolab上に構築します。グラボモードが有効になっていることを確認し、以下のセルを順に実行してください。\n",
|
30 |
+
"\n",
|
31 |
+
"**最近のcolabのアップデートにより、エラーダイアログ「WARNING: The following packages were previously imported in this runtime: [pydevd_plugins]」が出るが、「キャンセル」を選択して続行してください。**"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": null,
|
37 |
+
"metadata": {},
|
38 |
+
"outputs": [],
|
39 |
+
"source": [
|
40 |
+
"# このセルを実行して環境構築してください。\n",
|
41 |
+
"# エラーダイアログ「WARNING: The following packages were previously imported in this runtime: [pydevd_plugins]」が出るが「キャンセル」を選択して続行してください。\n",
|
42 |
+
"\n",
|
43 |
+
"!git clone https://github.com/litagin02/Style-Bert-VITS2.git\n",
|
44 |
+
"%cd Style-Bert-VITS2/\n",
|
45 |
+
"!pip install -r requirements.txt\n",
|
46 |
+
"!python initialize.py --skip_jvnv"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"cell_type": "code",
|
51 |
+
"execution_count": null,
|
52 |
+
"metadata": {},
|
53 |
+
"outputs": [],
|
54 |
+
"source": [
|
55 |
+
"# Google driveを使う方はこちらを実行してください。\n",
|
56 |
+
"\n",
|
57 |
+
"from google.colab import drive\n",
|
58 |
+
"drive.mount(\"/content/drive\")"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"cell_type": "markdown",
|
63 |
+
"metadata": {},
|
64 |
+
"source": [
|
65 |
+
"## 1. 初期設定\n",
|
66 |
+
"\n",
|
67 |
+
"学習とその結果を保存するディレクトリ名を指定します。\n",
|
68 |
+
"Google driveの場合はそのまま実行、カスタマイズしたい方は変更して実行してください。"
|
69 |
+
]
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"cell_type": "code",
|
73 |
+
"execution_count": 1,
|
74 |
+
"metadata": {},
|
75 |
+
"outputs": [],
|
76 |
+
"source": [
|
77 |
+
"# 学習に必要なファイルや途中経過が保存されるディレクトリ\n",
|
78 |
+
"dataset_root = \"/content/drive/MyDrive/Style-Bert-VITS2/Data\"\n",
|
79 |
+
"\n",
|
80 |
+
"# 学習結果(音声合成に必要なファイルたち)が保存されるディレクトリ\n",
|
81 |
+
"assets_root = \"/content/drive/MyDrive/Style-Bert-VITS2/model_assets\"\n",
|
82 |
+
"\n",
|
83 |
+
"import yaml\n",
|
84 |
+
"\n",
|
85 |
+
"\n",
|
86 |
+
"with open(\"configs/paths.yml\", \"w\", encoding=\"utf-8\") as f:\n",
|
87 |
+
" yaml.dump({\"dataset_root\": dataset_root, \"assets_root\": assets_root}, f)"
|
88 |
+
]
|
89 |
+
},
|
90 |
+
{
|
91 |
+
"cell_type": "markdown",
|
92 |
+
"metadata": {},
|
93 |
+
"source": [
|
94 |
+
"## 2. 学習に使うデータ準備\n",
|
95 |
+
"\n",
|
96 |
+
"すでに音声ファイル(1ファイル2-12秒程度)とその書き起こしデータがある場合は2.2を、ない場合は2.1を実行してください。"
|
97 |
+
]
|
98 |
+
},
|
99 |
+
{
|
100 |
+
"cell_type": "markdown",
|
101 |
+
"metadata": {},
|
102 |
+
"source": [
|
103 |
+
"### 2.1 音声ファイルからのデータセットの作成(ある人はスキップ可)\n",
|
104 |
+
"\n",
|
105 |
+
"音声ファイル(1ファイル2-12秒程度)とその書き起こしのデータセットを持っていない方は、(日本語の)音声ファイルのみから以下の手順でデータセットを作成することができます。Google drive上の`Style-Bert-VITS2/inputs/`フォルダに音声ファイル(wavファイル形式、1ファイルでも複数ファイルでも可)を置いて、下を実行すると、データセットが���られ、自動的に正しい場所へ配置されます。"
|
106 |
+
]
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"cell_type": "code",
|
110 |
+
"execution_count": null,
|
111 |
+
"metadata": {},
|
112 |
+
"outputs": [],
|
113 |
+
"source": [
|
114 |
+
"# 元となる音声ファイル(wav形式)を入れるディレクトリ\n",
|
115 |
+
"input_dir = \"/content/drive/MyDrive/Style-Bert-VITS2/inputs\"\n",
|
116 |
+
"# モデル名(話者名)を入力\n",
|
117 |
+
"model_name = \"your_model_name\"\n",
|
118 |
+
"\n",
|
119 |
+
"# こういうふうに書き起こして欲しいという例文(句読点の入れ方・笑い方や固有名詞等)\n",
|
120 |
+
"initial_prompt = \"こんにちは。元気、ですかー?ふふっ、私は……ちゃんと元気だよ!\"\n",
|
121 |
+
"\n",
|
122 |
+
"!python slice.py -i {input_dir} --model_name {model_name}\n",
|
123 |
+
"!python transcribe.py --model_name {model_name} --initial_prompt {initial_prompt} --use_hf_whisper"
|
124 |
+
]
|
125 |
+
},
|
126 |
+
{
|
127 |
+
"cell_type": "markdown",
|
128 |
+
"metadata": {},
|
129 |
+
"source": [
|
130 |
+
"成功したらそのまま3へ進んでください"
|
131 |
+
]
|
132 |
+
},
|
133 |
+
{
|
134 |
+
"cell_type": "markdown",
|
135 |
+
"metadata": {},
|
136 |
+
"source": [
|
137 |
+
"### 2.2 音声ファイルと書き起こしデータがすでにある場合\n",
|
138 |
+
"\n",
|
139 |
+
"指示に従って適切にデータセットを配置してください。\n",
|
140 |
+
"\n",
|
141 |
+
"次のセルを実行して、学習データをいれるフォルダ(1で設定した`dataset_root`)を作成します。"
|
142 |
+
]
|
143 |
+
},
|
144 |
+
{
|
145 |
+
"cell_type": "code",
|
146 |
+
"execution_count": 5,
|
147 |
+
"metadata": {
|
148 |
+
"id": "esCNJl704h52"
|
149 |
+
},
|
150 |
+
"outputs": [],
|
151 |
+
"source": [
|
152 |
+
"import os\n",
|
153 |
+
"\n",
|
154 |
+
"os.makedirs(dataset_root, exist_ok=True)"
|
155 |
+
]
|
156 |
+
},
|
157 |
+
{
|
158 |
+
"cell_type": "markdown",
|
159 |
+
"metadata": {},
|
160 |
+
"source": [
|
161 |
+
"次に、学習に必要なデータを、Google driveに作成された`Style-Bert-VITS2/Data`フォルダに配置します。\n",
|
162 |
+
"\n",
|
163 |
+
"まず音声データ(wavファイルで1ファイルが2-12秒程度の、長すぎず短すぎない発話のものをいくつか)と、書き起こしテキストを用意してください。wavファイル名やモデルの名前は空白を含まない半角で、wavファイルの拡張子は小文字`.wav`である必要があります。\n",
|
164 |
+
"\n",
|
165 |
+
"書き起こしテキストは、次の形式で記述してください。\n",
|
166 |
+
"```\n",
|
167 |
+
"****.wav|{話者名}|{言語ID、ZHかJPかEN}|{書き起こしテキスト}\n",
|
168 |
+
"```\n",
|
169 |
+
"\n",
|
170 |
+
"例:\n",
|
171 |
+
"```\n",
|
172 |
+
"wav_number1.wav|hanako|JP|こんにちは、聞こえて、いますか?\n",
|
173 |
+
"wav_next.wav|taro|JP|はい、聞こえています……。\n",
|
174 |
+
"english_teacher.wav|Mary|EN|How are you? I'm fine, thank you, and you?\n",
|
175 |
+
"...\n",
|
176 |
+
"```\n",
|
177 |
+
"日本語話者の単一話者データセットで構いません。\n",
|
178 |
+
"\n",
|
179 |
+
"### データセットの配置\n",
|
180 |
+
"\n",
|
181 |
+
"次にモデルの名前を適当に決めてください(空白を含まない半角英数字がよいです)。\n",
|
182 |
+
"そして、書き起こしファイルを`esd.list`という名前で保存し、またwavファイルも`raw`というフォルダを作成し、あなたのGoogle Driveの中の(上で自動的に作られるはずの)`Data`フォルダのなかに、次のように配置します。\n",
|
183 |
+
"```\n",
|
184 |
+
"├── Data\n",
|
185 |
+
"│ ├── {モデルの名前}\n",
|
186 |
+
"│ │ ├── esd.list\n",
|
187 |
+
"│ │ ├── raw\n",
|
188 |
+
"│ │ │ ├── ****.wav\n",
|
189 |
+
"│ │ │ ├── ****.wav\n",
|
190 |
+
"│ │ │ ├── ...\n",
|
191 |
+
"```"
|
192 |
+
]
|
193 |
+
},
|
194 |
+
{
|
195 |
+
"cell_type": "markdown",
|
196 |
+
"metadata": {
|
197 |
+
"id": "5r85-W20ECcr"
|
198 |
+
},
|
199 |
+
"source": [
|
200 |
+
"## 3. 学習の前処理\n",
|
201 |
+
"\n",
|
202 |
+
"次に学習の前処理を行います。必要なパラメータをここで指定します。次のセルに設定等を入力して実行してください。「~~かどうか」は`True`もしくは`False`を指定してください。"
|
203 |
+
]
|
204 |
+
},
|
205 |
+
{
|
206 |
+
"cell_type": "code",
|
207 |
+
"execution_count": 6,
|
208 |
+
"metadata": {
|
209 |
+
"id": "CXR7kjuF5GlE"
|
210 |
+
},
|
211 |
+
"outputs": [],
|
212 |
+
"source": [
|
213 |
+
"# 上でつけたフォルダの名前`Data/{model_name}/`\n",
|
214 |
+
"model_name = \"your_model_name\"\n",
|
215 |
+
"\n",
|
216 |
+
"# JP-Extra (日本語特化版)を使うかどうか。日本語の能力が向上する代わりに英語と中国語は使えなくなります。\n",
|
217 |
+
"use_jp_extra = True\n",
|
218 |
+
"\n",
|
219 |
+
"# 学習のバッチサイズ。VRAMのはみ出具合に応じて調整してください。\n",
|
220 |
+
"batch_size = 4\n",
|
221 |
+
"\n",
|
222 |
+
"# 学習のエポック数(データセットを合計何周するか)。\n",
|
223 |
+
"# 100で多すぎるほどかもしれませんが、もっと多くやると質が上がるのかもしれません。\n",
|
224 |
+
"epochs = 100\n",
|
225 |
+
"\n",
|
226 |
+
"# 保存頻度。何ステップごとにモデルを保存するか。分からなければデフォルトのままで。\n",
|
227 |
+
"save_every_steps = 1000\n",
|
228 |
+
"\n",
|
229 |
+
"# 音声ファイルの音量を正規化するかどうか\n",
|
230 |
+
"normalize = False\n",
|
231 |
+
"\n",
|
232 |
+
"# 音声ファイルの開始・終了にある無音区間を削除するかどうか\n",
|
233 |
+
"trim = False\n",
|
234 |
+
"\n",
|
235 |
+
"# 読みのエラーが出た場合にどうするか。\n",
|
236 |
+
"# \"raise\"ならテキスト前処理が終わったら中断、\"skip\"なら読めない行は学習に使わない、\"use\"なら無理やり使う\n",
|
237 |
+
"yomi_error = \"skip\""
|
238 |
+
]
|
239 |
+
},
|
240 |
+
{
|
241 |
+
"cell_type": "markdown",
|
242 |
+
"metadata": {},
|
243 |
+
"source": [
|
244 |
+
"上のセルが実行されたら、次のセルを実行して学習の前処理を行います。"
|
245 |
+
]
|
246 |
+
},
|
247 |
+
{
|
248 |
+
"cell_type": "code",
|
249 |
+
"execution_count": null,
|
250 |
+
"metadata": {
|
251 |
+
"colab": {
|
252 |
+
"base_uri": "https://localhost:8080/"
|
253 |
+
},
|
254 |
+
"id": "xMVaOIPLabV5",
|
255 |
+
"outputId": "15fac868-9132-45d9-9f5f-365b6aeb67b0"
|
256 |
+
},
|
257 |
+
"outputs": [],
|
258 |
+
"source": [
|
259 |
+
"from gradio_tabs.train import preprocess_all\n",
|
260 |
+
"\n",
|
261 |
+
"preprocess_all(\n",
|
262 |
+
" model_name=model_name,\n",
|
263 |
+
" batch_size=batch_size,\n",
|
264 |
+
" epochs=epochs,\n",
|
265 |
+
" save_every_steps=save_every_steps,\n",
|
266 |
+
" num_processes=2,\n",
|
267 |
+
" normalize=normalize,\n",
|
268 |
+
" trim=trim,\n",
|
269 |
+
" freeze_EN_bert=False,\n",
|
270 |
+
" freeze_JP_bert=False,\n",
|
271 |
+
" freeze_ZH_bert=False,\n",
|
272 |
+
" freeze_style=False,\n",
|
273 |
+
" freeze_decoder=False, # ここをTrueにするともしかしたら違う結果になるかもしれません。\n",
|
274 |
+
" use_jp_extra=use_jp_extra,\n",
|
275 |
+
" val_per_lang=0,\n",
|
276 |
+
" log_interval=200,\n",
|
277 |
+
" yomi_error=yomi_error\n",
|
278 |
+
")"
|
279 |
+
]
|
280 |
+
},
|
281 |
+
{
|
282 |
+
"cell_type": "markdown",
|
283 |
+
"metadata": {},
|
284 |
+
"source": [
|
285 |
+
"## 4. 学習\n",
|
286 |
+
"\n",
|
287 |
+
"前処理が正常に終わったら、学習を行います。次のセルを実行すると学習が始まります。\n",
|
288 |
+
"\n",
|
289 |
+
"学習の結果は、上で指定した`save_every_steps`の間隔で、Google Driveの中の`Style-Bert-VITS2/Data/{モデルの名前}/model_assets/`フォルダに保存されます。\n",
|
290 |
+
"\n",
|
291 |
+
"このフォルダをダウンロードし、ローカルのStyle-Bert-VITS2の`model_assets`フォルダに上書きすれば、学習結果を使うことができます。"
|
292 |
+
]
|
293 |
+
},
|
294 |
+
{
|
295 |
+
"cell_type": "code",
|
296 |
+
"execution_count": null,
|
297 |
+
"metadata": {
|
298 |
+
"colab": {
|
299 |
+
"base_uri": "https://localhost:8080/"
|
300 |
+
},
|
301 |
+
"id": "laieKrbEb6Ij",
|
302 |
+
"outputId": "72238c88-f294-4ed9-84f6-84c1c17999ca"
|
303 |
+
},
|
304 |
+
"outputs": [],
|
305 |
+
"source": [
|
306 |
+
"# 上でつけたモデル名を入力。学習を途中からする場合はきちんとモデルが保存されているフォルダ名を入力。\n",
|
307 |
+
"model_name = \"your_model_name\"\n",
|
308 |
+
"\n",
|
309 |
+
"\n",
|
310 |
+
"import yaml\n",
|
311 |
+
"from gradio_tabs.train import get_path\n",
|
312 |
+
"\n",
|
313 |
+
"dataset_path, _, _, _, config_path = get_path(model_name)\n",
|
314 |
+
"\n",
|
315 |
+
"with open(\"default_config.yml\", \"r\", encoding=\"utf-8\") as f:\n",
|
316 |
+
" yml_data = yaml.safe_load(f)\n",
|
317 |
+
"yml_data[\"model_name\"] = model_name\n",
|
318 |
+
"with open(\"config.yml\", \"w\", encoding=\"utf-8\") as f:\n",
|
319 |
+
" yaml.dump(yml_data, f, allow_unicode=True)"
|
320 |
+
]
|
321 |
+
},
|
322 |
+
{
|
323 |
+
"cell_type": "code",
|
324 |
+
"execution_count": null,
|
325 |
+
"metadata": {},
|
326 |
+
"outputs": [],
|
327 |
+
"source": [
|
328 |
+
"# 日本語特化版を「使う」場合\n",
|
329 |
+
"!python train_ms_jp_extra.py --config {config_path} --model {dataset_path} --assets_root {assets_root}"
|
330 |
+
]
|
331 |
+
},
|
332 |
+
{
|
333 |
+
"cell_type": "code",
|
334 |
+
"execution_count": null,
|
335 |
+
"metadata": {},
|
336 |
+
"outputs": [],
|
337 |
+
"source": [
|
338 |
+
"# 日本語特化版を「使わない」場合\n",
|
339 |
+
"!python train_ms.py --config {config_path} --model {dataset_path} --assets_root {assets_root}"
|
340 |
+
]
|
341 |
+
},
|
342 |
+
{
|
343 |
+
"cell_type": "code",
|
344 |
+
"execution_count": null,
|
345 |
+
"metadata": {
|
346 |
+
"colab": {
|
347 |
+
"base_uri": "https://localhost:8080/"
|
348 |
+
},
|
349 |
+
"id": "c7g0hrdeP1Tl",
|
350 |
+
"outputId": "94f9a6f6-027f-4554-ce0c-60ac56251c22"
|
351 |
+
},
|
352 |
+
"outputs": [],
|
353 |
+
"source": [
|
354 |
+
"# 学習結果を試す・マージ・���タイル分けはこちらから\n",
|
355 |
+
"!python app.py --share"
|
356 |
+
]
|
357 |
+
}
|
358 |
+
],
|
359 |
+
"metadata": {
|
360 |
+
"accelerator": "GPU",
|
361 |
+
"colab": {
|
362 |
+
"gpuType": "T4",
|
363 |
+
"provenance": []
|
364 |
+
},
|
365 |
+
"kernelspec": {
|
366 |
+
"display_name": "Python 3",
|
367 |
+
"name": "python3"
|
368 |
+
},
|
369 |
+
"language_info": {
|
370 |
+
"codemirror_mode": {
|
371 |
+
"name": "ipython",
|
372 |
+
"version": 3
|
373 |
+
},
|
374 |
+
"file_extension": ".py",
|
375 |
+
"mimetype": "text/x-python",
|
376 |
+
"name": "python",
|
377 |
+
"nbconvert_exporter": "python",
|
378 |
+
"pygments_lexer": "ipython3",
|
379 |
+
"version": "3.10.11"
|
380 |
+
}
|
381 |
+
},
|
382 |
+
"nbformat": 4,
|
383 |
+
"nbformat_minor": 0
|
384 |
+
}
|
config.py
ADDED
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
@Desc: 全局配置文件读取
|
3 |
+
"""
|
4 |
+
|
5 |
+
import os
|
6 |
+
import shutil
|
7 |
+
from typing import Dict, List
|
8 |
+
|
9 |
+
import torch
|
10 |
+
import yaml
|
11 |
+
|
12 |
+
from style_bert_vits2.logging import logger
|
13 |
+
|
14 |
+
|
15 |
+
# If not cuda available, set possible devices to cpu
|
16 |
+
cuda_available = torch.cuda.is_available()
|
17 |
+
|
18 |
+
|
19 |
+
class Resample_config:
|
20 |
+
"""重采样配置"""
|
21 |
+
|
22 |
+
def __init__(self, in_dir: str, out_dir: str, sampling_rate: int = 44100):
|
23 |
+
self.sampling_rate: int = sampling_rate # 目标采样率
|
24 |
+
self.in_dir: str = in_dir # 待处理音频目录路径
|
25 |
+
self.out_dir: str = out_dir # 重采样输出路径
|
26 |
+
|
27 |
+
@classmethod
|
28 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
29 |
+
"""从字典中生成实例"""
|
30 |
+
|
31 |
+
# 不检查路径是否有效,此逻辑在resample.py中处理
|
32 |
+
data["in_dir"] = os.path.join(dataset_path, data["in_dir"])
|
33 |
+
data["out_dir"] = os.path.join(dataset_path, data["out_dir"])
|
34 |
+
|
35 |
+
return cls(**data)
|
36 |
+
|
37 |
+
|
38 |
+
class Preprocess_text_config:
|
39 |
+
"""数据预处理配置"""
|
40 |
+
|
41 |
+
def __init__(
|
42 |
+
self,
|
43 |
+
transcription_path: str,
|
44 |
+
cleaned_path: str,
|
45 |
+
train_path: str,
|
46 |
+
val_path: str,
|
47 |
+
config_path: str,
|
48 |
+
val_per_lang: int = 5,
|
49 |
+
max_val_total: int = 10000,
|
50 |
+
clean: bool = True,
|
51 |
+
):
|
52 |
+
self.transcription_path: str = (
|
53 |
+
transcription_path # 原始文本文件路径,文本格式应为{wav_path}|{speaker_name}|{language}|{text}。
|
54 |
+
)
|
55 |
+
self.cleaned_path: str = (
|
56 |
+
cleaned_path # 数据清洗后文本路径,可以不填。不填则将在原始文本目录生成
|
57 |
+
)
|
58 |
+
self.train_path: str = (
|
59 |
+
train_path # 训练集路径,可以不填。不填则将在原始文本目录生成
|
60 |
+
)
|
61 |
+
self.val_path: str = (
|
62 |
+
val_path # 验证集路径,可以不填。不填则将在原始文本目录生成
|
63 |
+
)
|
64 |
+
self.config_path: str = config_path # 配置文件路径
|
65 |
+
self.val_per_lang: int = val_per_lang # 每个speaker的验证集条数
|
66 |
+
self.max_val_total: int = (
|
67 |
+
max_val_total # 验证集最大条数,多于的会被截断并放到训练集中
|
68 |
+
)
|
69 |
+
self.clean: bool = clean # 是否进行数据清洗
|
70 |
+
|
71 |
+
@classmethod
|
72 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
73 |
+
"""从字典中生成实例"""
|
74 |
+
|
75 |
+
data["transcription_path"] = os.path.join(
|
76 |
+
dataset_path, data["transcription_path"]
|
77 |
+
)
|
78 |
+
if data["cleaned_path"] == "" or data["cleaned_path"] is None:
|
79 |
+
data["cleaned_path"] = None
|
80 |
+
else:
|
81 |
+
data["cleaned_path"] = os.path.join(dataset_path, data["cleaned_path"])
|
82 |
+
data["train_path"] = os.path.join(dataset_path, data["train_path"])
|
83 |
+
data["val_path"] = os.path.join(dataset_path, data["val_path"])
|
84 |
+
data["config_path"] = os.path.join(dataset_path, data["config_path"])
|
85 |
+
|
86 |
+
return cls(**data)
|
87 |
+
|
88 |
+
|
89 |
+
class Bert_gen_config:
|
90 |
+
"""bert_gen 配置"""
|
91 |
+
|
92 |
+
def __init__(
|
93 |
+
self,
|
94 |
+
config_path: str,
|
95 |
+
num_processes: int = 1,
|
96 |
+
device: str = "cuda",
|
97 |
+
use_multi_device: bool = False,
|
98 |
+
):
|
99 |
+
self.config_path = config_path
|
100 |
+
self.num_processes = num_processes
|
101 |
+
if not cuda_available:
|
102 |
+
device = "cpu"
|
103 |
+
self.device = device
|
104 |
+
self.use_multi_device = use_multi_device
|
105 |
+
|
106 |
+
@classmethod
|
107 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
108 |
+
data["config_path"] = os.path.join(dataset_path, data["config_path"])
|
109 |
+
|
110 |
+
return cls(**data)
|
111 |
+
|
112 |
+
|
113 |
+
class Style_gen_config:
|
114 |
+
"""style_gen 配置"""
|
115 |
+
|
116 |
+
def __init__(
|
117 |
+
self,
|
118 |
+
config_path: str,
|
119 |
+
num_processes: int = 4,
|
120 |
+
device: str = "cuda",
|
121 |
+
):
|
122 |
+
self.config_path = config_path
|
123 |
+
self.num_processes = num_processes
|
124 |
+
if not cuda_available:
|
125 |
+
device = "cpu"
|
126 |
+
self.device = device
|
127 |
+
|
128 |
+
@classmethod
|
129 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
130 |
+
data["config_path"] = os.path.join(dataset_path, data["config_path"])
|
131 |
+
|
132 |
+
return cls(**data)
|
133 |
+
|
134 |
+
|
135 |
+
class Train_ms_config:
|
136 |
+
"""训练配置"""
|
137 |
+
|
138 |
+
def __init__(
|
139 |
+
self,
|
140 |
+
config_path: str,
|
141 |
+
env: Dict[str, any],
|
142 |
+
# base: Dict[str, any],
|
143 |
+
model_dir: str,
|
144 |
+
num_workers: int,
|
145 |
+
spec_cache: bool,
|
146 |
+
keep_ckpts: int,
|
147 |
+
):
|
148 |
+
self.env = env # 需要加载的环境变量
|
149 |
+
# self.base = base # 底模配置
|
150 |
+
self.model_dir = model_dir # 训练模型存储目录,该路径为相对于dataset_path的路径,而非项目根目录
|
151 |
+
self.config_path = config_path # 配置文件路径
|
152 |
+
self.num_workers = num_workers # worker数量
|
153 |
+
self.spec_cache = spec_cache # 是否启用spec缓存
|
154 |
+
self.keep_ckpts = keep_ckpts # ckpt数量
|
155 |
+
|
156 |
+
@classmethod
|
157 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
158 |
+
# data["model"] = os.path.join(dataset_path, data["model"])
|
159 |
+
data["config_path"] = os.path.join(dataset_path, data["config_path"])
|
160 |
+
|
161 |
+
return cls(**data)
|
162 |
+
|
163 |
+
|
164 |
+
class Webui_config:
|
165 |
+
"""webui 配置 (for webui.py, not supported now)"""
|
166 |
+
|
167 |
+
def __init__(
|
168 |
+
self,
|
169 |
+
device: str,
|
170 |
+
model: str,
|
171 |
+
config_path: str,
|
172 |
+
language_identification_library: str,
|
173 |
+
port: int = 7860,
|
174 |
+
share: bool = False,
|
175 |
+
debug: bool = False,
|
176 |
+
):
|
177 |
+
if not cuda_available:
|
178 |
+
device = "cpu"
|
179 |
+
self.device: str = device
|
180 |
+
self.model: str = model # 端口号
|
181 |
+
self.config_path: str = config_path # 是否公开部署,对外网开放
|
182 |
+
self.port: int = port # 是否开启debug模式
|
183 |
+
self.share: bool = share # 模型路径
|
184 |
+
self.debug: bool = debug # 配置文件路径
|
185 |
+
self.language_identification_library: str = (
|
186 |
+
language_identification_library # 语种识别库
|
187 |
+
)
|
188 |
+
|
189 |
+
@classmethod
|
190 |
+
def from_dict(cls, dataset_path: str, data: Dict[str, any]):
|
191 |
+
data["config_path"] = os.path.join(dataset_path, data["config_path"])
|
192 |
+
data["model"] = os.path.join(dataset_path, data["model"])
|
193 |
+
return cls(**data)
|
194 |
+
|
195 |
+
|
196 |
+
class Server_config:
|
197 |
+
def __init__(
|
198 |
+
self,
|
199 |
+
port: int = 5000,
|
200 |
+
device: str = "cuda",
|
201 |
+
limit: int = 100,
|
202 |
+
language: str = "JP",
|
203 |
+
origins: List[str] = None,
|
204 |
+
):
|
205 |
+
self.port: int = port
|
206 |
+
if not cuda_available:
|
207 |
+
device = "cpu"
|
208 |
+
self.device: str = device
|
209 |
+
self.language: str = language
|
210 |
+
self.limit: int = limit
|
211 |
+
self.origins: List[str] = origins
|
212 |
+
|
213 |
+
@classmethod
|
214 |
+
def from_dict(cls, data: Dict[str, any]):
|
215 |
+
return cls(**data)
|
216 |
+
|
217 |
+
|
218 |
+
class Translate_config:
|
219 |
+
"""翻译api配置"""
|
220 |
+
|
221 |
+
def __init__(self, app_key: str, secret_key: str):
|
222 |
+
self.app_key = app_key
|
223 |
+
self.secret_key = secret_key
|
224 |
+
|
225 |
+
@classmethod
|
226 |
+
def from_dict(cls, data: Dict[str, any]):
|
227 |
+
return cls(**data)
|
228 |
+
|
229 |
+
|
230 |
+
class Config:
|
231 |
+
def __init__(self, config_path: str, path_config: dict[str, str]):
|
232 |
+
if not os.path.isfile(config_path) and os.path.isfile("default_config.yml"):
|
233 |
+
shutil.copy(src="default_config.yml", dst=config_path)
|
234 |
+
logger.info(
|
235 |
+
f"A configuration file {config_path} has been generated based on the default configuration file default_config.yml."
|
236 |
+
)
|
237 |
+
logger.info(
|
238 |
+
"If you have no special needs, please do not modify default_config.yml."
|
239 |
+
)
|
240 |
+
# sys.exit(0)
|
241 |
+
with open(config_path, "r", encoding="utf-8") as file:
|
242 |
+
yaml_config: Dict[str, any] = yaml.safe_load(file.read())
|
243 |
+
model_name: str = yaml_config["model_name"]
|
244 |
+
self.model_name: str = model_name
|
245 |
+
if "dataset_path" in yaml_config:
|
246 |
+
dataset_path = yaml_config["dataset_path"]
|
247 |
+
else:
|
248 |
+
dataset_path = os.path.join(path_config["dataset_root"], model_name)
|
249 |
+
self.dataset_path: str = dataset_path
|
250 |
+
self.assets_root: str = path_config["assets_root"]
|
251 |
+
self.out_dir = os.path.join(self.assets_root, model_name)
|
252 |
+
self.resample_config: Resample_config = Resample_config.from_dict(
|
253 |
+
dataset_path, yaml_config["resample"]
|
254 |
+
)
|
255 |
+
self.preprocess_text_config: Preprocess_text_config = (
|
256 |
+
Preprocess_text_config.from_dict(
|
257 |
+
dataset_path, yaml_config["preprocess_text"]
|
258 |
+
)
|
259 |
+
)
|
260 |
+
self.bert_gen_config: Bert_gen_config = Bert_gen_config.from_dict(
|
261 |
+
dataset_path, yaml_config["bert_gen"]
|
262 |
+
)
|
263 |
+
self.style_gen_config: Style_gen_config = Style_gen_config.from_dict(
|
264 |
+
dataset_path, yaml_config["style_gen"]
|
265 |
+
)
|
266 |
+
self.train_ms_config: Train_ms_config = Train_ms_config.from_dict(
|
267 |
+
dataset_path, yaml_config["train_ms"]
|
268 |
+
)
|
269 |
+
self.webui_config: Webui_config = Webui_config.from_dict(
|
270 |
+
dataset_path, yaml_config["webui"]
|
271 |
+
)
|
272 |
+
self.server_config: Server_config = Server_config.from_dict(
|
273 |
+
yaml_config["server"]
|
274 |
+
)
|
275 |
+
# self.translate_config: Translate_config = Translate_config.from_dict(
|
276 |
+
# yaml_config["translate"]
|
277 |
+
# )
|
278 |
+
|
279 |
+
|
280 |
+
with open(os.path.join("configs", "paths.yml"), "r", encoding="utf-8") as f:
|
281 |
+
path_config: dict[str, str] = yaml.safe_load(f.read())
|
282 |
+
# Should contain the following keys:
|
283 |
+
# - dataset_root: the root directory of the dataset, default to "Data"
|
284 |
+
# - assets_root: the root directory of the assets, default to "model_assets"
|
285 |
+
|
286 |
+
|
287 |
+
try:
|
288 |
+
config = Config("config.yml", path_config)
|
289 |
+
except (TypeError, KeyError):
|
290 |
+
logger.warning("Old config.yml found. Replace it with default_config.yml.")
|
291 |
+
shutil.copy(src="default_config.yml", dst="config.yml")
|
292 |
+
config = Config("config.yml", path_config)
|
configs/config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_name": "Dummy",
|
3 |
+
"train": {
|
4 |
+
"log_interval": 200,
|
5 |
+
"eval_interval": 1000,
|
6 |
+
"seed": 42,
|
7 |
+
"epochs": 1000,
|
8 |
+
"learning_rate": 0.0002,
|
9 |
+
"betas": [0.8, 0.99],
|
10 |
+
"eps": 1e-9,
|
11 |
+
"batch_size": 2,
|
12 |
+
"bf16_run": false,
|
13 |
+
"lr_decay": 0.99995,
|
14 |
+
"segment_size": 16384,
|
15 |
+
"init_lr_ratio": 1,
|
16 |
+
"warmup_epochs": 0,
|
17 |
+
"c_mel": 45,
|
18 |
+
"c_kl": 1.0,
|
19 |
+
"skip_optimizer": false,
|
20 |
+
"freeze_ZH_bert": false,
|
21 |
+
"freeze_JP_bert": false,
|
22 |
+
"freeze_EN_bert": false,
|
23 |
+
"freeze_style": false,
|
24 |
+
"freeze_encoder": false
|
25 |
+
},
|
26 |
+
"data": {
|
27 |
+
"use_jp_extra": false,
|
28 |
+
"training_files": "Data/Dummy/train.list",
|
29 |
+
"validation_files": "Data/Dummy/val.list",
|
30 |
+
"max_wav_value": 32768.0,
|
31 |
+
"sampling_rate": 44100,
|
32 |
+
"filter_length": 2048,
|
33 |
+
"hop_length": 512,
|
34 |
+
"win_length": 2048,
|
35 |
+
"n_mel_channels": 128,
|
36 |
+
"mel_fmin": 0.0,
|
37 |
+
"mel_fmax": null,
|
38 |
+
"add_blank": true,
|
39 |
+
"n_speakers": 1,
|
40 |
+
"cleaned_text": true,
|
41 |
+
"num_styles": 1,
|
42 |
+
"style2id": {
|
43 |
+
"Neutral": 0
|
44 |
+
}
|
45 |
+
},
|
46 |
+
"model": {
|
47 |
+
"use_spk_conditioned_encoder": true,
|
48 |
+
"use_noise_scaled_mas": true,
|
49 |
+
"use_mel_posterior_encoder": false,
|
50 |
+
"use_duration_discriminator": true,
|
51 |
+
"inter_channels": 192,
|
52 |
+
"hidden_channels": 192,
|
53 |
+
"filter_channels": 768,
|
54 |
+
"n_heads": 2,
|
55 |
+
"n_layers": 6,
|
56 |
+
"kernel_size": 3,
|
57 |
+
"p_dropout": 0.1,
|
58 |
+
"resblock": "1",
|
59 |
+
"resblock_kernel_sizes": [3, 7, 11],
|
60 |
+
"resblock_dilation_sizes": [
|
61 |
+
[1, 3, 5],
|
62 |
+
[1, 3, 5],
|
63 |
+
[1, 3, 5]
|
64 |
+
],
|
65 |
+
"upsample_rates": [8, 8, 2, 2, 2],
|
66 |
+
"upsample_initial_channel": 512,
|
67 |
+
"upsample_kernel_sizes": [16, 16, 8, 2, 2],
|
68 |
+
"n_layers_q": 3,
|
69 |
+
"use_spectral_norm": false,
|
70 |
+
"gin_channels": 256
|
71 |
+
},
|
72 |
+
"version": "2.4.1"
|
73 |
+
}
|
configs/config_jp_extra.json
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"model_name": "Dummy",
|
3 |
+
"train": {
|
4 |
+
"log_interval": 200,
|
5 |
+
"eval_interval": 1000,
|
6 |
+
"seed": 42,
|
7 |
+
"epochs": 1000,
|
8 |
+
"learning_rate": 0.0001,
|
9 |
+
"betas": [0.8, 0.99],
|
10 |
+
"eps": 1e-9,
|
11 |
+
"batch_size": 2,
|
12 |
+
"bf16_run": false,
|
13 |
+
"fp16_run": false,
|
14 |
+
"lr_decay": 0.99996,
|
15 |
+
"segment_size": 16384,
|
16 |
+
"init_lr_ratio": 1,
|
17 |
+
"warmup_epochs": 0,
|
18 |
+
"c_mel": 45,
|
19 |
+
"c_kl": 1.0,
|
20 |
+
"c_commit": 100,
|
21 |
+
"skip_optimizer": false,
|
22 |
+
"freeze_ZH_bert": false,
|
23 |
+
"freeze_JP_bert": false,
|
24 |
+
"freeze_EN_bert": false,
|
25 |
+
"freeze_emo": false,
|
26 |
+
"freeze_style": false,
|
27 |
+
"freeze_decoder": false
|
28 |
+
},
|
29 |
+
"data": {
|
30 |
+
"use_jp_extra": true,
|
31 |
+
"training_files": "Data/Dummy/train.list",
|
32 |
+
"validation_files": "Data/Dummy/val.list",
|
33 |
+
"max_wav_value": 32768.0,
|
34 |
+
"sampling_rate": 44100,
|
35 |
+
"filter_length": 2048,
|
36 |
+
"hop_length": 512,
|
37 |
+
"win_length": 2048,
|
38 |
+
"n_mel_channels": 128,
|
39 |
+
"mel_fmin": 0.0,
|
40 |
+
"mel_fmax": null,
|
41 |
+
"add_blank": true,
|
42 |
+
"n_speakers": 512,
|
43 |
+
"cleaned_text": true
|
44 |
+
},
|
45 |
+
"model": {
|
46 |
+
"use_spk_conditioned_encoder": true,
|
47 |
+
"use_noise_scaled_mas": true,
|
48 |
+
"use_mel_posterior_encoder": false,
|
49 |
+
"use_duration_discriminator": false,
|
50 |
+
"use_wavlm_discriminator": true,
|
51 |
+
"inter_channels": 192,
|
52 |
+
"hidden_channels": 192,
|
53 |
+
"filter_channels": 768,
|
54 |
+
"n_heads": 2,
|
55 |
+
"n_layers": 6,
|
56 |
+
"kernel_size": 3,
|
57 |
+
"p_dropout": 0.1,
|
58 |
+
"resblock": "1",
|
59 |
+
"resblock_kernel_sizes": [3, 7, 11],
|
60 |
+
"resblock_dilation_sizes": [
|
61 |
+
[1, 3, 5],
|
62 |
+
[1, 3, 5],
|
63 |
+
[1, 3, 5]
|
64 |
+
],
|
65 |
+
"upsample_rates": [8, 8, 2, 2, 2],
|
66 |
+
"upsample_initial_channel": 512,
|
67 |
+
"upsample_kernel_sizes": [16, 16, 8, 2, 2],
|
68 |
+
"n_layers_q": 3,
|
69 |
+
"use_spectral_norm": false,
|
70 |
+
"gin_channels": 512,
|
71 |
+
"slm": {
|
72 |
+
"model": "./slm/wavlm-base-plus",
|
73 |
+
"sr": 16000,
|
74 |
+
"hidden": 768,
|
75 |
+
"nlayers": 13,
|
76 |
+
"initial_channel": 64
|
77 |
+
}
|
78 |
+
},
|
79 |
+
"version": "2.4.1-JP-Extra"
|
80 |
+
}
|
configs/paths.yml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
assets_root: /content/drive/MyDrive/Style-Bert-VITS2C/model_assets
|
2 |
+
dataset_root: /content/drive/MyDrive/Style-Bert-VITS2C/Data
|
data_utils.py
ADDED
@@ -0,0 +1,458 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import random
|
3 |
+
import sys
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import torch
|
7 |
+
import torch.utils.data
|
8 |
+
from tqdm import tqdm
|
9 |
+
|
10 |
+
from config import config
|
11 |
+
from mel_processing import mel_spectrogram_torch, spectrogram_torch
|
12 |
+
from style_bert_vits2.logging import logger
|
13 |
+
from style_bert_vits2.models import commons
|
14 |
+
from style_bert_vits2.models.hyper_parameters import HyperParametersData
|
15 |
+
from style_bert_vits2.models.utils import load_filepaths_and_text, load_wav_to_torch
|
16 |
+
from style_bert_vits2.nlp import cleaned_text_to_sequence
|
17 |
+
|
18 |
+
|
19 |
+
"""Multi speaker version"""
|
20 |
+
|
21 |
+
|
22 |
+
class TextAudioSpeakerLoader(torch.utils.data.Dataset):
|
23 |
+
"""
|
24 |
+
1) loads audio, speaker_id, text pairs
|
25 |
+
2) normalizes text and converts them to sequences of integers
|
26 |
+
3) computes spectrograms from audio files.
|
27 |
+
"""
|
28 |
+
|
29 |
+
def __init__(self, audiopaths_sid_text: str, hparams: HyperParametersData):
|
30 |
+
self.audiopaths_sid_text = load_filepaths_and_text(audiopaths_sid_text)
|
31 |
+
self.max_wav_value = hparams.max_wav_value
|
32 |
+
self.sampling_rate = hparams.sampling_rate
|
33 |
+
self.filter_length = hparams.filter_length
|
34 |
+
self.hop_length = hparams.hop_length
|
35 |
+
self.win_length = hparams.win_length
|
36 |
+
self.sampling_rate = hparams.sampling_rate
|
37 |
+
self.spk_map = hparams.spk2id
|
38 |
+
self.hparams = hparams
|
39 |
+
self.use_jp_extra = getattr(hparams, "use_jp_extra", False)
|
40 |
+
|
41 |
+
self.use_mel_spec_posterior = getattr(
|
42 |
+
hparams, "use_mel_posterior_encoder", False
|
43 |
+
)
|
44 |
+
if self.use_mel_spec_posterior:
|
45 |
+
self.n_mel_channels = getattr(hparams, "n_mel_channels", 80)
|
46 |
+
|
47 |
+
self.cleaned_text = getattr(hparams, "cleaned_text", False)
|
48 |
+
|
49 |
+
self.add_blank = hparams.add_blank
|
50 |
+
self.min_text_len = getattr(hparams, "min_text_len", 1)
|
51 |
+
self.max_text_len = getattr(hparams, "max_text_len", 384)
|
52 |
+
|
53 |
+
random.seed(1234)
|
54 |
+
random.shuffle(self.audiopaths_sid_text)
|
55 |
+
self._filter()
|
56 |
+
|
57 |
+
def _filter(self):
|
58 |
+
"""
|
59 |
+
Filter text & store spec lengths
|
60 |
+
"""
|
61 |
+
# Store spectrogram lengths for Bucketing
|
62 |
+
# wav_length ~= file_size / (wav_channels * Bytes per dim) = file_size / (1 * 2)
|
63 |
+
# spec_length = wav_length // hop_length
|
64 |
+
|
65 |
+
audiopaths_sid_text_new = []
|
66 |
+
lengths = []
|
67 |
+
skipped = 0
|
68 |
+
logger.info("Init dataset...")
|
69 |
+
for _id, spk, language, text, phones, tone, word2ph in tqdm(
|
70 |
+
self.audiopaths_sid_text, file=sys.stdout
|
71 |
+
):
|
72 |
+
audiopath = f"{_id}"
|
73 |
+
if self.min_text_len <= len(phones) and len(phones) <= self.max_text_len:
|
74 |
+
phones = phones.split(" ")
|
75 |
+
tone = [int(i) for i in tone.split(" ")]
|
76 |
+
word2ph = [int(i) for i in word2ph.split(" ")]
|
77 |
+
audiopaths_sid_text_new.append(
|
78 |
+
[audiopath, spk, language, text, phones, tone, word2ph]
|
79 |
+
)
|
80 |
+
lengths.append(os.path.getsize(audiopath) // (2 * self.hop_length))
|
81 |
+
else:
|
82 |
+
skipped += 1
|
83 |
+
logger.info(
|
84 |
+
"skipped: "
|
85 |
+
+ str(skipped)
|
86 |
+
+ ", total: "
|
87 |
+
+ str(len(self.audiopaths_sid_text))
|
88 |
+
)
|
89 |
+
self.audiopaths_sid_text = audiopaths_sid_text_new
|
90 |
+
self.lengths = lengths
|
91 |
+
|
92 |
+
def get_audio_text_speaker_pair(self, audiopath_sid_text):
|
93 |
+
# separate filename, speaker_id and text
|
94 |
+
audiopath, sid, language, text, phones, tone, word2ph = audiopath_sid_text
|
95 |
+
|
96 |
+
bert, ja_bert, en_bert, phones, tone, language = self.get_text(
|
97 |
+
text, word2ph, phones, tone, language, audiopath
|
98 |
+
)
|
99 |
+
|
100 |
+
spec, wav = self.get_audio(audiopath)
|
101 |
+
sid = torch.LongTensor([int(self.spk_map[sid])])
|
102 |
+
style_vec = torch.FloatTensor(np.load(f"{audiopath}.npy"))
|
103 |
+
if self.use_jp_extra:
|
104 |
+
return (phones, spec, wav, sid, tone, language, ja_bert, style_vec)
|
105 |
+
else:
|
106 |
+
return (
|
107 |
+
phones,
|
108 |
+
spec,
|
109 |
+
wav,
|
110 |
+
sid,
|
111 |
+
tone,
|
112 |
+
language,
|
113 |
+
bert,
|
114 |
+
ja_bert,
|
115 |
+
en_bert,
|
116 |
+
style_vec,
|
117 |
+
)
|
118 |
+
|
119 |
+
def get_audio(self, filename):
|
120 |
+
audio, sampling_rate = load_wav_to_torch(filename)
|
121 |
+
if sampling_rate != self.sampling_rate:
|
122 |
+
raise ValueError(
|
123 |
+
"{} {} SR doesn't match target {} SR".format(
|
124 |
+
filename, sampling_rate, self.sampling_rate
|
125 |
+
)
|
126 |
+
)
|
127 |
+
audio_norm = audio / self.max_wav_value
|
128 |
+
audio_norm = audio_norm.unsqueeze(0)
|
129 |
+
spec_filename = filename.replace(".wav", ".spec.pt")
|
130 |
+
if self.use_mel_spec_posterior:
|
131 |
+
spec_filename = spec_filename.replace(".spec.pt", ".mel.pt")
|
132 |
+
try:
|
133 |
+
spec = torch.load(spec_filename)
|
134 |
+
except:
|
135 |
+
if self.use_mel_spec_posterior:
|
136 |
+
spec = mel_spectrogram_torch(
|
137 |
+
audio_norm,
|
138 |
+
self.filter_length,
|
139 |
+
self.n_mel_channels,
|
140 |
+
self.sampling_rate,
|
141 |
+
self.hop_length,
|
142 |
+
self.win_length,
|
143 |
+
self.hparams.mel_fmin,
|
144 |
+
self.hparams.mel_fmax,
|
145 |
+
center=False,
|
146 |
+
)
|
147 |
+
else:
|
148 |
+
spec = spectrogram_torch(
|
149 |
+
audio_norm,
|
150 |
+
self.filter_length,
|
151 |
+
self.sampling_rate,
|
152 |
+
self.hop_length,
|
153 |
+
self.win_length,
|
154 |
+
center=False,
|
155 |
+
)
|
156 |
+
spec = torch.squeeze(spec, 0)
|
157 |
+
if config.train_ms_config.spec_cache:
|
158 |
+
torch.save(spec, spec_filename)
|
159 |
+
return spec, audio_norm
|
160 |
+
|
161 |
+
def get_text(self, text, word2ph, phone, tone, language_str, wav_path):
|
162 |
+
phone, tone, language = cleaned_text_to_sequence(phone, tone, language_str)
|
163 |
+
if self.add_blank:
|
164 |
+
phone = commons.intersperse(phone, 0)
|
165 |
+
tone = commons.intersperse(tone, 0)
|
166 |
+
language = commons.intersperse(language, 0)
|
167 |
+
for i in range(len(word2ph)):
|
168 |
+
word2ph[i] = word2ph[i] * 2
|
169 |
+
word2ph[0] += 1
|
170 |
+
bert_path = wav_path.replace(".wav", ".bert.pt")
|
171 |
+
try:
|
172 |
+
bert_ori = torch.load(bert_path)
|
173 |
+
assert bert_ori.shape[-1] == len(phone)
|
174 |
+
except Exception as e:
|
175 |
+
logger.warning("Bert load Failed")
|
176 |
+
logger.warning(e)
|
177 |
+
|
178 |
+
if language_str == "ZH":
|
179 |
+
bert = bert_ori
|
180 |
+
ja_bert = torch.zeros(1024, len(phone))
|
181 |
+
en_bert = torch.zeros(1024, len(phone))
|
182 |
+
elif language_str == "JP":
|
183 |
+
bert = torch.zeros(1024, len(phone))
|
184 |
+
ja_bert = bert_ori
|
185 |
+
en_bert = torch.zeros(1024, len(phone))
|
186 |
+
elif language_str == "EN":
|
187 |
+
bert = torch.zeros(1024, len(phone))
|
188 |
+
ja_bert = torch.zeros(1024, len(phone))
|
189 |
+
en_bert = bert_ori
|
190 |
+
phone = torch.LongTensor(phone)
|
191 |
+
tone = torch.LongTensor(tone)
|
192 |
+
language = torch.LongTensor(language)
|
193 |
+
return bert, ja_bert, en_bert, phone, tone, language
|
194 |
+
|
195 |
+
def get_sid(self, sid):
|
196 |
+
sid = torch.LongTensor([int(sid)])
|
197 |
+
return sid
|
198 |
+
|
199 |
+
def __getitem__(self, index):
|
200 |
+
return self.get_audio_text_speaker_pair(self.audiopaths_sid_text[index])
|
201 |
+
|
202 |
+
def __len__(self):
|
203 |
+
return len(self.audiopaths_sid_text)
|
204 |
+
|
205 |
+
|
206 |
+
class TextAudioSpeakerCollate:
|
207 |
+
"""Zero-pads model inputs and targets"""
|
208 |
+
|
209 |
+
def __init__(self, return_ids=False, use_jp_extra=False):
|
210 |
+
self.return_ids = return_ids
|
211 |
+
self.use_jp_extra = use_jp_extra
|
212 |
+
|
213 |
+
def __call__(self, batch):
|
214 |
+
"""Collate's training batch from normalized text, audio and speaker identities
|
215 |
+
PARAMS
|
216 |
+
------
|
217 |
+
batch: [text_normalized, spec_normalized, wav_normalized, sid]
|
218 |
+
"""
|
219 |
+
# Right zero-pad all one-hot text sequences to max input length
|
220 |
+
_, ids_sorted_decreasing = torch.sort(
|
221 |
+
torch.LongTensor([x[1].size(1) for x in batch]), dim=0, descending=True
|
222 |
+
)
|
223 |
+
|
224 |
+
max_text_len = max([len(x[0]) for x in batch])
|
225 |
+
max_spec_len = max([x[1].size(1) for x in batch])
|
226 |
+
max_wav_len = max([x[2].size(1) for x in batch])
|
227 |
+
|
228 |
+
text_lengths = torch.LongTensor(len(batch))
|
229 |
+
spec_lengths = torch.LongTensor(len(batch))
|
230 |
+
wav_lengths = torch.LongTensor(len(batch))
|
231 |
+
sid = torch.LongTensor(len(batch))
|
232 |
+
|
233 |
+
text_padded = torch.LongTensor(len(batch), max_text_len)
|
234 |
+
tone_padded = torch.LongTensor(len(batch), max_text_len)
|
235 |
+
language_padded = torch.LongTensor(len(batch), max_text_len)
|
236 |
+
# This is ZH bert if not use_jp_extra, JA bert if use_jp_extra
|
237 |
+
bert_padded = torch.FloatTensor(len(batch), 1024, max_text_len)
|
238 |
+
if not self.use_jp_extra:
|
239 |
+
ja_bert_padded = torch.FloatTensor(len(batch), 1024, max_text_len)
|
240 |
+
en_bert_padded = torch.FloatTensor(len(batch), 1024, max_text_len)
|
241 |
+
style_vec = torch.FloatTensor(len(batch), 256)
|
242 |
+
|
243 |
+
spec_padded = torch.FloatTensor(len(batch), batch[0][1].size(0), max_spec_len)
|
244 |
+
wav_padded = torch.FloatTensor(len(batch), 1, max_wav_len)
|
245 |
+
text_padded.zero_()
|
246 |
+
tone_padded.zero_()
|
247 |
+
language_padded.zero_()
|
248 |
+
spec_padded.zero_()
|
249 |
+
wav_padded.zero_()
|
250 |
+
bert_padded.zero_()
|
251 |
+
if not self.use_jp_extra:
|
252 |
+
ja_bert_padded.zero_()
|
253 |
+
en_bert_padded.zero_()
|
254 |
+
style_vec.zero_()
|
255 |
+
|
256 |
+
for i in range(len(ids_sorted_decreasing)):
|
257 |
+
row = batch[ids_sorted_decreasing[i]]
|
258 |
+
|
259 |
+
text = row[0]
|
260 |
+
text_padded[i, : text.size(0)] = text
|
261 |
+
text_lengths[i] = text.size(0)
|
262 |
+
|
263 |
+
spec = row[1]
|
264 |
+
spec_padded[i, :, : spec.size(1)] = spec
|
265 |
+
spec_lengths[i] = spec.size(1)
|
266 |
+
|
267 |
+
wav = row[2]
|
268 |
+
wav_padded[i, :, : wav.size(1)] = wav
|
269 |
+
wav_lengths[i] = wav.size(1)
|
270 |
+
|
271 |
+
sid[i] = row[3]
|
272 |
+
|
273 |
+
tone = row[4]
|
274 |
+
tone_padded[i, : tone.size(0)] = tone
|
275 |
+
|
276 |
+
language = row[5]
|
277 |
+
language_padded[i, : language.size(0)] = language
|
278 |
+
|
279 |
+
bert = row[6]
|
280 |
+
bert_padded[i, :, : bert.size(1)] = bert
|
281 |
+
|
282 |
+
if self.use_jp_extra:
|
283 |
+
style_vec[i, :] = row[7]
|
284 |
+
else:
|
285 |
+
ja_bert = row[7]
|
286 |
+
ja_bert_padded[i, :, : ja_bert.size(1)] = ja_bert
|
287 |
+
|
288 |
+
en_bert = row[8]
|
289 |
+
en_bert_padded[i, :, : en_bert.size(1)] = en_bert
|
290 |
+
style_vec[i, :] = row[9]
|
291 |
+
|
292 |
+
if self.use_jp_extra:
|
293 |
+
return (
|
294 |
+
text_padded,
|
295 |
+
text_lengths,
|
296 |
+
spec_padded,
|
297 |
+
spec_lengths,
|
298 |
+
wav_padded,
|
299 |
+
wav_lengths,
|
300 |
+
sid,
|
301 |
+
tone_padded,
|
302 |
+
language_padded,
|
303 |
+
bert_padded,
|
304 |
+
style_vec,
|
305 |
+
)
|
306 |
+
else:
|
307 |
+
return (
|
308 |
+
text_padded,
|
309 |
+
text_lengths,
|
310 |
+
spec_padded,
|
311 |
+
spec_lengths,
|
312 |
+
wav_padded,
|
313 |
+
wav_lengths,
|
314 |
+
sid,
|
315 |
+
tone_padded,
|
316 |
+
language_padded,
|
317 |
+
bert_padded,
|
318 |
+
ja_bert_padded,
|
319 |
+
en_bert_padded,
|
320 |
+
style_vec,
|
321 |
+
)
|
322 |
+
|
323 |
+
|
324 |
+
class DistributedBucketSampler(torch.utils.data.distributed.DistributedSampler):
|
325 |
+
"""
|
326 |
+
Maintain similar input lengths in a batch.
|
327 |
+
Length groups are specified by boundaries.
|
328 |
+
Ex) boundaries = [b1, b2, b3] -> any batch is included either {x | b1 < length(x) <=b2} or {x | b2 < length(x) <= b3}.
|
329 |
+
|
330 |
+
It removes samples which are not included in the boundaries.
|
331 |
+
Ex) boundaries = [b1, b2, b3] -> any x s.t. length(x) <= b1 or length(x) > b3 are discarded.
|
332 |
+
"""
|
333 |
+
|
334 |
+
def __init__(
|
335 |
+
self,
|
336 |
+
dataset,
|
337 |
+
batch_size,
|
338 |
+
boundaries,
|
339 |
+
num_replicas=None,
|
340 |
+
rank=None,
|
341 |
+
shuffle=True,
|
342 |
+
):
|
343 |
+
super().__init__(dataset, num_replicas=num_replicas, rank=rank, shuffle=shuffle)
|
344 |
+
self.lengths = dataset.lengths
|
345 |
+
self.batch_size = batch_size
|
346 |
+
self.boundaries = boundaries
|
347 |
+
|
348 |
+
self.buckets, self.num_samples_per_bucket = self._create_buckets()
|
349 |
+
logger.info(f"Bucket info: {self.num_samples_per_bucket}")
|
350 |
+
# logger.info(
|
351 |
+
# f"Unused samples: {len(self.lengths) - sum(self.num_samples_per_bucket)}"
|
352 |
+
# )
|
353 |
+
# ↑マイナスになることあるし、別にこれは使われないサンプル数ではないようだ……
|
354 |
+
# バケットの仕組みはよく分からない
|
355 |
+
|
356 |
+
self.total_size = sum(self.num_samples_per_bucket)
|
357 |
+
self.num_samples = self.total_size // self.num_replicas
|
358 |
+
|
359 |
+
def _create_buckets(self):
|
360 |
+
buckets = [[] for _ in range(len(self.boundaries) - 1)]
|
361 |
+
for i in range(len(self.lengths)):
|
362 |
+
length = self.lengths[i]
|
363 |
+
idx_bucket = self._bisect(length)
|
364 |
+
if idx_bucket != -1:
|
365 |
+
buckets[idx_bucket].append(i)
|
366 |
+
|
367 |
+
try:
|
368 |
+
for i in range(len(buckets) - 1, 0, -1):
|
369 |
+
if len(buckets[i]) == 0:
|
370 |
+
buckets.pop(i)
|
371 |
+
self.boundaries.pop(i + 1)
|
372 |
+
assert all(len(bucket) > 0 for bucket in buckets)
|
373 |
+
# When one bucket is not traversed
|
374 |
+
except Exception as e:
|
375 |
+
logger.info("Bucket warning ", e)
|
376 |
+
for i in range(len(buckets) - 1, -1, -1):
|
377 |
+
if len(buckets[i]) == 0:
|
378 |
+
buckets.pop(i)
|
379 |
+
self.boundaries.pop(i + 1)
|
380 |
+
|
381 |
+
num_samples_per_bucket = []
|
382 |
+
for i in range(len(buckets)):
|
383 |
+
len_bucket = len(buckets[i])
|
384 |
+
total_batch_size = self.num_replicas * self.batch_size
|
385 |
+
rem = (
|
386 |
+
total_batch_size - (len_bucket % total_batch_size)
|
387 |
+
) % total_batch_size
|
388 |
+
num_samples_per_bucket.append(len_bucket + rem)
|
389 |
+
return buckets, num_samples_per_bucket
|
390 |
+
|
391 |
+
def __iter__(self):
|
392 |
+
# deterministically shuffle based on epoch
|
393 |
+
g = torch.Generator()
|
394 |
+
g.manual_seed(self.epoch)
|
395 |
+
|
396 |
+
indices = []
|
397 |
+
if self.shuffle:
|
398 |
+
for bucket in self.buckets:
|
399 |
+
indices.append(torch.randperm(len(bucket), generator=g).tolist())
|
400 |
+
else:
|
401 |
+
for bucket in self.buckets:
|
402 |
+
indices.append(list(range(len(bucket))))
|
403 |
+
|
404 |
+
batches = []
|
405 |
+
for i in range(len(self.buckets)):
|
406 |
+
bucket = self.buckets[i]
|
407 |
+
len_bucket = len(bucket)
|
408 |
+
if len_bucket == 0:
|
409 |
+
continue
|
410 |
+
ids_bucket = indices[i]
|
411 |
+
num_samples_bucket = self.num_samples_per_bucket[i]
|
412 |
+
|
413 |
+
# add extra samples to make it evenly divisible
|
414 |
+
rem = num_samples_bucket - len_bucket
|
415 |
+
ids_bucket = (
|
416 |
+
ids_bucket
|
417 |
+
+ ids_bucket * (rem // len_bucket)
|
418 |
+
+ ids_bucket[: (rem % len_bucket)]
|
419 |
+
)
|
420 |
+
|
421 |
+
# subsample
|
422 |
+
ids_bucket = ids_bucket[self.rank :: self.num_replicas]
|
423 |
+
|
424 |
+
# batching
|
425 |
+
for j in range(len(ids_bucket) // self.batch_size):
|
426 |
+
batch = [
|
427 |
+
bucket[idx]
|
428 |
+
for idx in ids_bucket[
|
429 |
+
j * self.batch_size : (j + 1) * self.batch_size
|
430 |
+
]
|
431 |
+
]
|
432 |
+
batches.append(batch)
|
433 |
+
|
434 |
+
if self.shuffle:
|
435 |
+
batch_ids = torch.randperm(len(batches), generator=g).tolist()
|
436 |
+
batches = [batches[i] for i in batch_ids]
|
437 |
+
self.batches = batches
|
438 |
+
|
439 |
+
assert len(self.batches) * self.batch_size == self.num_samples
|
440 |
+
return iter(self.batches)
|
441 |
+
|
442 |
+
def _bisect(self, x, lo=0, hi=None):
|
443 |
+
if hi is None:
|
444 |
+
hi = len(self.boundaries) - 1
|
445 |
+
|
446 |
+
if hi > lo:
|
447 |
+
mid = (hi + lo) // 2
|
448 |
+
if self.boundaries[mid] < x and x <= self.boundaries[mid + 1]:
|
449 |
+
return mid
|
450 |
+
elif x <= self.boundaries[mid]:
|
451 |
+
return self._bisect(x, lo, mid)
|
452 |
+
else:
|
453 |
+
return self._bisect(x, mid + 1, hi)
|
454 |
+
else:
|
455 |
+
return -1
|
456 |
+
|
457 |
+
def __len__(self):
|
458 |
+
return self.num_samples // self.batch_size
|
default_config.yml
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
model_name: "model_name"
|
2 |
+
|
3 |
+
# If you want to use a specific dataset path, uncomment the following line.
|
4 |
+
# Otherwise, the dataset path is `{dataset_root}/{model_name}`.
|
5 |
+
|
6 |
+
# dataset_path: "your/dataset/path"
|
7 |
+
|
8 |
+
resample:
|
9 |
+
sampling_rate: 44100
|
10 |
+
in_dir: "raw"
|
11 |
+
out_dir: "wavs"
|
12 |
+
|
13 |
+
preprocess_text:
|
14 |
+
transcription_path: "esd.list"
|
15 |
+
cleaned_path: ""
|
16 |
+
train_path: "train.list"
|
17 |
+
val_path: "val.list"
|
18 |
+
config_path: "config.json"
|
19 |
+
val_per_lang: 0
|
20 |
+
max_val_total: 12
|
21 |
+
clean: true
|
22 |
+
|
23 |
+
bert_gen:
|
24 |
+
config_path: "config.json"
|
25 |
+
num_processes: 1
|
26 |
+
device: "cuda"
|
27 |
+
use_multi_device: false
|
28 |
+
|
29 |
+
style_gen:
|
30 |
+
config_path: "config.json"
|
31 |
+
num_processes: 4
|
32 |
+
device: "cuda"
|
33 |
+
|
34 |
+
train_ms:
|
35 |
+
env:
|
36 |
+
MASTER_ADDR: "localhost"
|
37 |
+
MASTER_PORT: 10086
|
38 |
+
WORLD_SIZE: 1
|
39 |
+
LOCAL_RANK: 0
|
40 |
+
RANK: 0
|
41 |
+
model_dir: "models" # The directory to save the model (for training), relative to `{dataset_root}/{model_name}`.
|
42 |
+
config_path: "config.json"
|
43 |
+
num_workers: 16
|
44 |
+
spec_cache: True
|
45 |
+
keep_ckpts: 1 # Set this to 0 to keep all checkpoints
|
46 |
+
|
47 |
+
webui: # For `webui.py`, which is not supported yet in Style-Bert-VITS2.
|
48 |
+
# 推理设备
|
49 |
+
device: "cuda"
|
50 |
+
# 模型路径
|
51 |
+
model: "models/G_8000.pth"
|
52 |
+
# 配置文件路径
|
53 |
+
config_path: "config.json"
|
54 |
+
# 端口号
|
55 |
+
port: 7860
|
56 |
+
# 是否公开部署,对外网开放
|
57 |
+
share: false
|
58 |
+
# 是否开启debug模式
|
59 |
+
debug: false
|
60 |
+
# 语种识别库,可选langid, fastlid
|
61 |
+
language_identification_library: "langid"
|
62 |
+
|
63 |
+
# server_fastapi's config
|
64 |
+
server:
|
65 |
+
port: 5000
|
66 |
+
device: "cuda"
|
67 |
+
language: "JP"
|
68 |
+
limit: 100
|
69 |
+
origins:
|
70 |
+
- "*"
|
default_style.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
from pathlib import Path
|
4 |
+
from typing import Union
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
|
8 |
+
from style_bert_vits2.constants import DEFAULT_STYLE
|
9 |
+
from style_bert_vits2.logging import logger
|
10 |
+
|
11 |
+
|
12 |
+
def set_style_config(json_path: Path, output_path: Path):
|
13 |
+
with open(json_path, "r", encoding="utf-8") as f:
|
14 |
+
json_dict = json.load(f)
|
15 |
+
json_dict["data"]["num_styles"] = 1
|
16 |
+
json_dict["data"]["style2id"] = {DEFAULT_STYLE: 0}
|
17 |
+
with open(output_path, "w", encoding="utf-8") as f:
|
18 |
+
json.dump(json_dict, f, indent=2, ensure_ascii=False)
|
19 |
+
logger.info(f"Save style config (only {DEFAULT_STYLE}) to {output_path}")
|
20 |
+
|
21 |
+
|
22 |
+
def save_neutral_vector(wav_dir: Union[Path, str], output_path: Union[Path, str]):
|
23 |
+
wav_dir = Path(wav_dir)
|
24 |
+
output_path = Path(output_path)
|
25 |
+
embs = []
|
26 |
+
for file in wav_dir.rglob("*.npy"):
|
27 |
+
xvec = np.load(file)
|
28 |
+
embs.append(np.expand_dims(xvec, axis=0))
|
29 |
+
|
30 |
+
x = np.concatenate(embs, axis=0) # (N, 256)
|
31 |
+
mean = np.mean(x, axis=0) # (256,)
|
32 |
+
only_mean = np.stack([mean]) # (1, 256)
|
33 |
+
np.save(output_path, only_mean)
|
34 |
+
logger.info(f"Saved mean style vector to {output_path}")
|
dict_data/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
*
|
2 |
+
!.gitignore
|
3 |
+
!default.csv
|
docs/CHANGELOG.md
ADDED
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Changelog
|
2 |
+
|
3 |
+
## v2.4.1 (2024-03-16)
|
4 |
+
|
5 |
+
**batファイルでのインストール・アップデート方法の変更**(それ以外の変更はありません)
|
6 |
+
|
7 |
+
諸事情により、インストール・アップデートのbatファイルを変更しました(Gitが使えないのでバージョンアップ時のアップデートの対応が困難だったため、Gitがない環境の場合はPortableGitをダウンロードして使うように)。
|
8 |
+
|
9 |
+
伴って、これまでWindowsでbatファイルをダブルクリックしてインストールしていた方は**再インストールが必須**となります。大変申し訳ありません。
|
10 |
+
|
11 |
+
### インストール手順
|
12 |
+
|
13 |
+
(インストールの流れは変わりませんが、batファイルは変わっているので、新しいzipを必ずダウンロードしてください)
|
14 |
+
|
15 |
+
- [sbv2.zip](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.4.1/sbv2.zip)をダウンロードし、解凍してください。
|
16 |
+
- グラボがある方は、`Install-Style-Bert-VITS2.bat`をダブルクリックします。
|
17 |
+
- グラボがない方は、`Install-Style-Bert-VITS2-CPU.bat`をダブルクリックします。CPU版では学習はできませんが、音声合成とマージは可能です。
|
18 |
+
|
19 |
+
### アップデート手順
|
20 |
+
|
21 |
+
**以前のバージョンからのアップデート**
|
22 |
+
|
23 |
+
今までの環境を全て削除して新しくインストールする必要があります。
|
24 |
+
移行方法:
|
25 |
+
- 重要なデータが入っている可能性のある`Data`フォルダと`model_assets`フォルダをバックアップ
|
26 |
+
- 上のインストール手順から、新しい場所にStyle-Bert-VITS2をインストール
|
27 |
+
- インストールが終了したら、バックアップした`Data`フォルダと`model_assets`フォルダを新しい`Style-Bert-VITS2`フォルダにコピー
|
28 |
+
- これまでインストールされていたフォルダ(batファイルたち含む)は削除しても構いません
|
29 |
+
|
30 |
+
**今後のアップデート**
|
31 |
+
|
32 |
+
今後は、新しくインストールされた中の`Update-Style-Bert-VITS2.bat`をダブルクリックしてください。今までの`Update-Style-Bert-VITS2.bat`等のファイルは使えません。
|
33 |
+
|
34 |
+
## v2.4.0 (2024-03-15)
|
35 |
+
|
36 |
+
大規模リファクタリング・日本語処理のワーカー化と機能追加等。データセット作り・学習・音声合成・マージ・スタイルWebUIは全て`app.py` (`App.bat`) へ統一されましたのでご注意ください。
|
37 |
+
|
38 |
+
### アップデート手順
|
39 |
+
- 2.3未満(辞書・エディター追加前)からのアップデートの場合は、[Update-to-Dict-Editor.bat](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.4.0/Update-to-Dict-Editor.bat)をダウンロードし、`Style-Bert-VITS2`フォルダがある場所(インストールbatファイルとかがあったところ)においてダブルクリックしてください。
|
40 |
+
- それ以外の場合は、単純に今までの`Update-Style-Bert-VITS2.bat`でアップデートできます。
|
41 |
+
- ただしアップデートにより多くのファイルが移動したり不要になったりしたので、それらを削除したい場合は[Clean.bat](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.4.0/Clean.bat)を`Update-Style-Bert-VITS2.bat`と同じ場所に保存して実行してください。
|
42 |
+
|
43 |
+
### 内部改善
|
44 |
+
|
45 |
+
- [tsukumijimaさんによる大規模リファクタリングのプルリク](https://github.com/litagin02/Style-Bert-VITS2/pull/92) によって、内部コードが非常に整理され可読性が高まりライブラリ化もされた。[tsukumijimaさん](https://github.com/tsukumijima) 大変な作業を本当にありがとうございます!
|
46 |
+
- ライブラリとして`pip install style-bert-vits2`によりすぐにインストールでき、音声合成部分の機能が使えます(使用例は[/library.ipynb](/library.ipynb)を参照してください)
|
47 |
+
- その他このプルリクに動機づけられ、多くのコードのリファクタリング・型アノテーションの追加等を行った
|
48 |
+
- 日本語処理のpyopenjtalkをソケット通信を用いて別プロセス化し、複数同時に学習や音声合成を立ち上げても辞書の競合エラーが起きないように。[kale4eat](https://github.com/kale4eat) さんによる[PR](https://github.com/litagin02/Style-Bert-VITS2/pull/89) です、ありがとうございます!
|
49 |
+
|
50 |
+
### バグ修正
|
51 |
+
|
52 |
+
- 上記にもある通り、音声合成と学習前処理など、日本語処理を扱うものを2つ以上起動しようとするとエラーが発生する仕様の解決。ユーザー辞書は追加すれば常にどこからでも適応されます。
|
53 |
+
- `raw`フォルダの直下でなくサブフォルダ内に音声ファイルがある場合に、`wavs`フォルダでもその構造が保たれてしまい、書き起こしファイルとの整合性が取れなくなる挙動を修正し、常に`wav`フォルダ直下へ`wav`ファイルを保存するように変更
|
54 |
+
- スライス時に元ファイル名にピリオド `.` が含まれると、スライス後のファイル名がおかしくなるバグの修正
|
55 |
+
|
56 |
+
### 機能改善・追加
|
57 |
+
|
58 |
+
- 各種WebUIを一つ`app.py` `App.bat` に統一
|
59 |
+
- その他以下の変更や、軽微なUI・説明文の改善等
|
60 |
+
|
61 |
+
**データセット作成**
|
62 |
+
|
63 |
+
- スライス処理の高速化(マルチスレッドにした、大量にスライス元ファイルファイルがある場合に高速になります)、またスライス元のファイルを`wav`以外の`mp3`や`ogg`などの形式にも対応
|
64 |
+
- スライス処理時に、ファイル名にスライスされた開始終了区間を含めるオプションを追加([aka7774](https://github.com/aka7774) さんによるPRです、ありがとうございます!)
|
65 |
+
- 書き起こしの高速化、またHugging FaceのWhisperモデルを使うオプションを追加。バッチサイズを上げることでVRAMを食う代わりに速度が大幅に向上します。
|
66 |
+
|
67 |
+
**学習**
|
68 |
+
|
69 |
+
- 学習元の音声ファイル(`Data/モデル名/raw`にいれるやつ)を、`wav`以外の`mp3`や`ogg`などの形式にも対応(前処理段階で自動的に`wav`ファイルに変換されます)(ただし変わらず1ファイル2-12秒程度の範囲の長さが望ましい)
|
70 |
+
|
71 |
+
**音声合成**
|
72 |
+
|
73 |
+
- 音声合成時に、生成音声の音の高さ(音高)と抑揚の幅を調整できるように(ただし音質が少し劣化する)。`App.bat`や`Editor.bat`のどちらからでも使えます。
|
74 |
+
- `Editor.bat`の複数話者モデルでの話者指定を可能に
|
75 |
+
- `Editor.bat`で、改行を含む文字列をペーストすると自動的に欄が増えるように。また「↑↓」キーで欄を追加・行き来できるように(エディター側で以前に既にアプデしていました)
|
76 |
+
- `Editor.bat`でモデル一覧のリロードをメニューに追加
|
77 |
+
|
78 |
+
**API**
|
79 |
+
|
80 |
+
- `server_fastapi.py`の実行時に全てのモデルファイルを読み込もうとする挙動を修正。音声合成がリクエストされて初めてそのモデルを読み込むように変更(APIを使わない音声合成のときと同じ挙動)
|
81 |
+
- `server_fastapi.py`の音声合成エンドポイント`/voice`について、GETメソッドに加えてPOSTメソッドを追加。GETメソッドでは多くの制約があるようなのでPOSTを使うことが推奨されます。
|
82 |
+
|
83 |
+
**CLI**
|
84 |
+
|
85 |
+
- `preprocess_text.py`で、書き起こしファイルでの音声ファイル名を自動的に正しい`Data/モデル名/wavs/`へ書き換える`--correct_path`オプションの追加(WebUIでは今までもこの挙動でした)
|
86 |
+
- その他上述のデータセット作成の機能追加に伴うCLIのオプションの追加(詳しくは[CLI.md](/docs/CLI.md)を参照)
|
87 |
+
|
88 |
+
## v2.3.1 (2024-02-27)
|
89 |
+
|
90 |
+
### バグ修正
|
91 |
+
- colabの学習用ノートブックが動かなかったのを修正
|
92 |
+
- `App.bat`や`server_fastapi.py`では読めない文字でまだエラーが発生するようになっていたので、推論時は必ず読めない文字を無視して強引に読むように挙動を変更
|
93 |
+
|
94 |
+
### 改善
|
95 |
+
- 読みが取得できない場合に、テキスト前処理完了時にエラーで中断する今までの挙動に加えて、「読み取得失敗ファイルを学習に使わずに進める」もしくは「読めない文字を無視して読んでファイルを学習に使い進める」というオプションを追加。
|
96 |
+
- マージ方法に線形補間の他に球面線形補完を追加 ([@frodo821](https://github.com/frodo821) さんによるPRです、ありがとうございます!)
|
97 |
+
- デプロイ用`.dockerignore`を更新
|
98 |
+
|
99 |
+
### アップデート手順
|
100 |
+
- 2.3未満からのアップデートの場合は、[Update-to-Dict-Editor.bat](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.3/Update-to-Dict-Editor.bat)をダウンロードし、`Style-Bert-VITS2`フォルダがある場所(インストールbatファイルとかがあったところ)においてダブルクリックしてください。
|
101 |
+
- 2.3からのアップデートの場合は、単純に今までの`Update-Style-Bert-VITS2.bat`でアップデートできます。
|
102 |
+
|
103 |
+
## v2.3 (2024-02-26)
|
104 |
+
|
105 |
+
### 大きな変更
|
106 |
+
|
107 |
+
大きい変更をいくつかしたため、**アップデートはまた専用の手順**が必要です。下記の指示にしたがってください。
|
108 |
+
|
109 |
+
#### ユーザー辞書機能
|
110 |
+
あらかじめ辞書に固有名詞を追加することができ、それが**学習時**・**音声合成時**の読み取得部分に適応されます。辞書の追加・編集は次のエディタ経由で行ってください。または、手持ちのOpenJTalkのcsv形式の辞書がある場合は、`dict_data/default.csv`ファイルを直接上書きや追加しても可能です。
|
111 |
+
|
112 |
+
使えそうな辞書(ライセンス等は各自ご確認ください)���他に良いのがあったら教えて下さい):
|
113 |
+
|
114 |
+
- [WariHima/Kanayomi-dict](https://github.com/WariHima/KanaYomi-dict)
|
115 |
+
- [takana-v/tsumu_dic](https://github.com/takana-v/tsumu_dic)
|
116 |
+
|
117 |
+
|
118 |
+
辞書機能部分の[実装](/text/user_dict/) は、中のREADMEにある通り、[VOICEVOX Editor](https://github.com/VOICEVOX/voicevox) のものを使っており、この部分のコードライセンスはLGPL-3.0です。
|
119 |
+
|
120 |
+
#### 音声合成専用エディタ
|
121 |
+
|
122 |
+
[🤗 オンラインデモはこちらから](https://huggingface.co/spaces/litagin/Style-Bert-VITS2-Editor-Demo)
|
123 |
+
|
124 |
+
音声合成専用エディタを追加。今までのWebUIでできた機能のほか、次のような機能が使えます(つまり既存の日本語音声合成ソフトウェアのエディタを真似ました):
|
125 |
+
- セリフ単位でキャラや設定を変更しながら原稿を作り、それを一括で生成したり、原稿を保存等したり読み込んだり
|
126 |
+
- GUIよる分かりやすいアクセント調整
|
127 |
+
- ユーザー辞書への単語追加や編集
|
128 |
+
|
129 |
+
`Editor.bat`をダブルクリックか`python server_editor.py --inbrowser`で起動します。エディター部分は[こちらの別リポジトリ](https://github.com/litagin02/Style-Bert-VITS2-Editor)になります。フロントエンド初心者なのでプルリクや改善案等をお待ちしています。
|
130 |
+
|
131 |
+
### バグ修正
|
132 |
+
|
133 |
+
- 特定の状況で読みが正しく取得できず `list index out of range` となるバグの修正
|
134 |
+
- 前処理時に、書き起こしファイルのある行の形式が不正だと、書き起こしファイルのそれ以降の内容が消えてしまうバグの修正
|
135 |
+
- faster-whisperが1.0.0にメジャーバージョンアップされ(今のところ)大幅に劣化したので、バージョンを0.10.1へ固定
|
136 |
+
|
137 |
+
### 改善
|
138 |
+
|
139 |
+
- テキスト前処理時に、読みの取得の失敗等があった場合に、処理を中断せず、エラーがおきた箇所を`text_error.log`ファイルへ保存するように変更。
|
140 |
+
- 音声合成時に、読めない文字があったときはエラーを起こさず、その部分を無視して読み上げるように変更(学習段階ではエラーを出します)
|
141 |
+
- コマンドラインで前処理や学習が簡単にできるよう、前処理を行う`preprocess_all.py`を追加(詳しくは[CLI.md](/docs/CLI.md)を参照)
|
142 |
+
- 学習の際に、自動的に自分のhugging faceリポジトリへ結果をアップロードするオプションを追加。コマンドライン引数で`--repo_id username/my_model`のように指定してください(詳しくは[CLI.md](/docs/CLI.md)を参照)。🤗の無制限ストレージが使えるのでクラウドでの学習に便利です。
|
143 |
+
- 学習時にデコーダー部分を凍結するオプションの追加。品質がもしかしたら上がるかもしれません。
|
144 |
+
- `initialize.py`に引数`--dataset_root`と`--assets_root`を追加し、`configs/paths.yml`をその時点で変更できるようにした
|
145 |
+
|
146 |
+
### その他
|
147 |
+
|
148 |
+
- [paperspaceでの学習の手引きを追加](/docs/paperspace.md)、paperspaceでのimageに使える[Dockerfile](/Dockerfile.train)を追加
|
149 |
+
- [CLIでの各種処理の実行の仕方を追加](/docs/CLI.md)
|
150 |
+
- [Hugging Face spacesで遊べる音声合成エディタ](https://huggingface.co/spaces/litagin/Style-Bert-VITS2-Editor-Demo)をデプロイするための[Dockerfile](Dockerfile.deploy)を追加
|
151 |
+
|
152 |
+
### アップデート手順
|
153 |
+
|
154 |
+
- [Update-to-Dict-Editor.bat](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.3/Update-to-Dict-Editor.bat)をダウンロードし、`Style-Bert-VITS2`フォルダがある場所(インストールbatファイルとかがあったところ)においてダブルクリックしてください。
|
155 |
+
|
156 |
+
- 手動での場合は、以下の手順で実行してください:
|
157 |
+
```bash
|
158 |
+
git pull
|
159 |
+
venv\Scripts\activate
|
160 |
+
pip uninstall pyopenjtalk-prebuilt
|
161 |
+
pip install -U -r requirements.txt
|
162 |
+
# python initialize.py # これを1.x系からのアップデートの場合は実行してください
|
163 |
+
python server_editor.py --inbrowser
|
164 |
+
```
|
165 |
+
|
166 |
+
### 新規インストール手順
|
167 |
+
[このzip](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.3/Style-Bert-VITS2.zip)をダウンロードし、解凍してください。
|
168 |
+
を展開し、`Install-Style-Bert-VITS2.bat`をダブルクリックしてください。
|
169 |
+
|
170 |
+
|
171 |
+
## v2.2 (2024-02-09)
|
172 |
+
|
173 |
+
### 変更・機能追加
|
174 |
+
- bfloat16オプションはデメリットしか無さそうなので、常にオフで学習するよう変更
|
175 |
+
- バッチサイズのデフォルトを4から2に変更。学習が遅い場合はバッチサイズを下げて試してみて、VRAMに余裕があれば上げてください。JP-Extra使用時でのバッチサイズごとのVRAM使用量目安は、1: 6GB, 2: 8GB, 3: 10GB, 4: 12GB くらいのようです。
|
176 |
+
- 学習の際の検証データ数をデフォルトで0に変更し、また検証データ数を学習用WebUIで指定でき���ようにした
|
177 |
+
- Tensorboardのログ間隔を学習用WebUIで指定できるようにした
|
178 |
+
- UIのテーマを`common/constants.py`の`GRADIO_THEME`で指定できるようにした
|
179 |
+
|
180 |
+
### バグ修正
|
181 |
+
- JP-Extra使用時にバッチサイズが1だと学習中にエラーが発生するバグを修正
|
182 |
+
- 「こんにちは!?!?!?!?」等、感嘆符等の記号が連続すると学習・音声合成でエラーになるバグを修正
|
183 |
+
- `—` (em dash, U+2014) や `―` (quotation dash, U+2015) 等のダッシュやハイフンの各種変種が、種類によって`-`(通常の半角ハイフン)に正規化されたりされていなかったりする処理を、全て正規化するように修正
|
184 |
+
|
185 |
+
## v2.1 (2024-02-07)
|
186 |
+
|
187 |
+
### 変更
|
188 |
+
- 学習の際、デフォルトではbfloat16オプションを使わないよう変更(学習が発散したり質が下がることがある模様)
|
189 |
+
- 学習の際のメモリ使用量を削減しようと頑張った
|
190 |
+
|
191 |
+
### バグ修正や改善
|
192 |
+
- 学習WebUIからTensorboardのログを見れるように
|
193 |
+
- 音声合成(やそのAPI)において、同時に別の話者が選択され音声合成がリクエストされた場合に発生するエラーを修正
|
194 |
+
- モデルマージ時に、そのレシピを`recipe.json`ファイルへ保存するように変更
|
195 |
+
- 「改行で分けて生成」がより感情が乗る旨の明記等、軽微な説明文の改善
|
196 |
+
- 「`ーーそれは面白い`」や「`なるほど。ーーーそういうことか。`」等、長音記号の前が母音でない場合、長音記号`ー`でなくダッシュ`―`の勘違いだと思われるので、ダッシュ記号として処理するように変更
|
197 |
+
|
198 |
+
## v2.0.1 (2024-02-05)
|
199 |
+
|
200 |
+
軽微なバグ修正や改善
|
201 |
+
- スタイルベクトルに`NaN`が含まれていた場合(主に音声ファイルが極端に短い場合に発生)、それを学習リストから除外するように修正
|
202 |
+
- colabにマージの追加
|
203 |
+
- 学習時のプログレスバーの表示がおかしかったのを修正
|
204 |
+
- デフォルトのjvnvモデルをJP-Extra版にアップデート。新しいモデルを使いたい方は手動で[こちら](https://huggingface.co/litagin/style_bert_vits2_jvnv/tree/main)からダウンロードするか、`python initialize.py`をするか、[このbatファイル](https://github.com/litagin02/Style-Bert-VITS2/releases/download/2.0.1/Update-to-JP-Extra.bat)を`Style-Bert-VITS2`フォルダがある場所(インストールbatファイルとかがあったところ)においてダブルクリックしてください。
|
205 |
+
|
206 |
+
## v2.0 (2024-02-03)
|
207 |
+
|
208 |
+
### 大きい変更
|
209 |
+
モデル構造に [Bert-VITS2の日本語特化モデル JP-Extra](https://github.com/fishaudio/Bert-VITS2/releases/tag/JP-Exta) を取り込んだものを使えるように変更、[事前学習モデル](https://huggingface.co/litagin/Style-Bert-VITS2-2.0-base-JP-Extra)も[Bert-VITS2 JP-Extra](https://huggingface.co/Stardust-minus/Bert-VITS2-Japanese-Extra)のものを改造してStyle-Bert-VITS2で使えるようにしました (モデル構造を見直して日本語での学習をしていただいた [@Stardust-minus](https://github.com/Stardust-minus) 様に感謝します)
|
210 |
+
- これにより、日本語の発音やアクセントや抑揚や自然性が向上する傾向があります
|
211 |
+
- スタイルベクトルを使ったスタイルの操作は変わらず使えます
|
212 |
+
- ただしJP-Extraでは英語と中国語の音声合成は(現状は)できません
|
213 |
+
- 旧モデルも引き続き使うことができ、また旧モデルで学習することもできます
|
214 |
+
- デフォルトのJVNVモデルは現在は旧verのままです
|
215 |
+
|
216 |
+
### 改善
|
217 |
+
- `Merge.bat`で、声音マージを、より細かく「声質」と「声の高さ」の点でマージできるように。
|
218 |
+
|
219 |
+
### バグ修正
|
220 |
+
- PyTorchのバージョンに由来するバグを修正(torchのバージョンを2.1.2に固定)
|
221 |
+
- `―`(ダッシュ、長音記号ではない)が2連続すると学習・音声合成でエラーになるバグを修正
|
222 |
+
- 「三円」等「ん+母音」のアクセントの仮名表記が「サネン」等になり、また偶にエラーが発生する問題を修正(「ん」の音素表記を内部的には「N」で統一)
|
223 |
+
|
224 |
+
## v1.3 (2024-01-09)
|
225 |
+
|
226 |
+
### 大きい変更
|
227 |
+
- 元々のBert-VITS2に存在した、日本語の発音・アクセント処理部分のバグを修正・リファクタリング
|
228 |
+
- `車両`が`シャリヨオ`、`思う`が`オモオ`、`見つける`が`ミッケル`等に発音・学習されており、その単語以降のアクセント情報が全て死んでいた
|
229 |
+
- `私はそれを見る`のアクセントが`ワ➚タシ➘ワ ソ➚レ➘オ ミ➘ル`だったのを`ワ➚タシワ ソ➚レオ ミ➘ル`に修正
|
230 |
+
- 学習・音声合成で無視されていたアルファベット・ギリシャ文字を無視しないように変更(基本はアルファベット読みだけど簡単な単語は読めるらしい、学習の際は念のためカタカナ等にしたほうがよいです)
|
231 |
+
- 修正の影響で、前処理時に(今まで無視されていた)読めない漢字等で引っかかるようになりました。その場合は書き起こしを確認して修正するようにしてください。
|
232 |
+
- アクセントを調整して音声合成できるように(完全に制御できるわけではないが改善される場合がある)。
|
233 |
+
|
234 |
+
これまでのモデルもこれまで通り使え、アクセントや発音等が改善される可能性があります。新しいバージョンで学習し直すとより良くなる可能性もあります。が劇的に良くなるかは分かりません。
|
235 |
+
|
236 |
+
### 改善
|
237 |
+
- `Dataset.bat`の音声スライスと書き起こしをよりカスタマイズできるように(スライスの秒数設定や書き起こしのWhisperモデル指定や言語指定等)
|
238 |
+
- `Style.bat`のスタイル分けで、スタイルごとのサンプル音声を指定した数だけ複数再生できるように。また新しい次元削減方法(UMAP)と新しいスタイル分けの方法(DBSCAN)を追加(UMAPのほうがよくスタイルが分かれるかもしれません)
|
239 |
+
- `App.bat`での音声合成時に複数話者モデルの場合に話者を指定できるように
|
240 |
+
- colabの[ノートブック](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)で、音声ファイルのみからデータセットを作成するオプション部分を追加
|
241 |
+
- クラウド実行等の際にパスの指定をこちらでできるように、パスの設定を`configs/paths.yml`にまとめた(colabの[ノートブック](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)もそれに伴って更新)。デフォルトは`dataset_root: Data`と`assets_root: model_assets`なので、クラウド等でやる方はここを変更してください。
|
242 |
+
- どのステップ数の出力がよいかの「一つの」指標として [SpeechMOS](https://github.com/tarepan/SpeechMOS) を使うスクリプトを追加:
|
243 |
+
```bash
|
244 |
+
python speech_mos.py -m <model_name>
|
245 |
+
```
|
246 |
+
ステップごとの自然性評価が表示され、`mos_results`フォルダの`mos_{model_name}.csv`と`mos_{model_name}.png`に結果が保存される。読み上げさせたい文章を変えたかったら中のファイルを弄って各自調整してください。あくまでアクセントや感情表現や抑揚を全く考えない基準での評価で、目安のひとつなので、実際に読み上げさせて選別するのが一番だと思います。
|
247 |
+
- 学習時のウォームアップオプションを機能するように( [@kale4eat](https://github.com/kale4eat) 様によるPRです、ありがとうございます!)。前処理時に生成される`config.json`の`train`の`warmup_epochs`を変更することで、ウォームアップのエポック数を変更できます。デフォルトは`0`で今までと同じ学習率の挙動です。
|
248 |
+
|
249 |
+
### その他
|
250 |
+
- `Dataset.bat`の音声スライスでノーマライズ機能を削除(学習前処理で行えるため)
|
251 |
+
- `Train.bat`の音量ノーマライズと無音切り詰めをデフォルトでオフに変更
|
252 |
+
- 学習時の進捗を全体エポック数で表示し、学習全体の進捗を見やすいように( [@RedRayz](https://github.com/RedRayz) 様によるPRです、ありがとうございます!)
|
253 |
+
- その他バグ修正等( [@tinjyuu](https://github.com/@tinjyuu) 様、 [@darai0512](https://github.com/darai0512) 様ありがとうございます!)
|
254 |
+
- `config.json`にスタイル埋め込み部分を学習しない`freeze_style`オプションを追加(デフォルトは`false`)
|
255 |
+
|
256 |
+
### TIPS
|
257 |
+
- 日本語学習の場合、`config.json`の`freeze_bert`と`freeze_en_bert`を`true`にしておくと、英語と中国語の発話能力が学習の過程で落ちないかもしれませんが、あまり比較していなので分かりません。
|
258 |
+
|
259 |
+
## v1.2 (2023-12-31)
|
260 |
+
|
261 |
+
- グラボがないユーザーでの音声合成をサポート、`Install-Style-Bert-VITS2-CPU.bat`でインストール。
|
262 |
+
- Google Colabでの学習をサポート、[ノートブック](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)を追加
|
263 |
+
- 音声合成のAPIサーバーを追加、`python server_fastapi.py`で起動します。API仕様は起動後に`/docs`にて確認ください。( [@darai0512](https://github.com/darai0512) 様によるPRです、ありがとうございます!)
|
264 |
+
- 学習時に自動的にデフォルトスタイル Neutral を生成するように。特にスタイル指定が必要のない方は、学習したらそのまま音声合成を試せます。これまで通りスタイルを自分で作ることもできます。
|
265 |
+
- マージ機能の新規追加: `Merge.bat`, `webui_merge.py`
|
266 |
+
- 前処理のリサンプリング時に音声ファイルの開始・終了部分の無音を削除するオプションを追加(デフォルトでオン)
|
267 |
+
- `スタイルテキスト (style text)`がスタイル指定と紛らわしかったので、`アシストテキスト (assist text)`に変更
|
268 |
+
- その他コードのリファクタリング
|
269 |
+
|
270 |
+
## v1.1 (2023-12-29)
|
271 |
+
- TrainとDatasetのWebUIの改良・調整(一括事前処理ボタン等)
|
272 |
+
- 前処理のリサンプリング時に音量を正規化するオプションを追加(デフォルトでオン)
|
273 |
+
|
274 |
+
## v1.0 (2023-12-27)
|
275 |
+
- 初版
|
docs/CLI.md
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CLI
|
2 |
+
|
3 |
+
## 0. Install and global paths settings
|
4 |
+
|
5 |
+
```bash
|
6 |
+
git clone https://github.com/litagin02/Style-Bert-VITS2.git
|
7 |
+
cd Style-Bert-VITS2
|
8 |
+
python -m venv venv
|
9 |
+
venv\Scripts\activate
|
10 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
11 |
+
pip install -r requirements.txt
|
12 |
+
```
|
13 |
+
|
14 |
+
Then download the necessary models and the default TTS model, and set the global paths.
|
15 |
+
```bash
|
16 |
+
python initialize.py [--skip_jvnv] [--dataset_root <path>] [--assets_root <path>]
|
17 |
+
```
|
18 |
+
|
19 |
+
Optional:
|
20 |
+
- `--skip_jvnv`: Skip downloading the default JVNV voice models (use this if you only have to train your own models).
|
21 |
+
- `--dataset_root`: Default: `Data`. Root directory of the training dataset. The training dataset of `{model_name}` should be placed in `{dataset_root}/{model_name}`.
|
22 |
+
- `--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}`.
|
23 |
+
|
24 |
+
|
25 |
+
## 1. Dataset preparation
|
26 |
+
|
27 |
+
### 1.1. Slice audio files
|
28 |
+
|
29 |
+
The following audio formats are supported: ".wav", ".flac", ".mp3", ".ogg", ".opus".
|
30 |
+
```bash
|
31 |
+
python slice.py --model_name <model_name> [-i <input_dir>] [-m <min_sec>] [-M <max_sec>] [--time_suffix]
|
32 |
+
```
|
33 |
+
|
34 |
+
Required:
|
35 |
+
- `model_name`: Name of the speaker (to be used as the name of the trained model).
|
36 |
+
|
37 |
+
Optional:
|
38 |
+
- `input_dir`: Path to the directory containing the audio files to slice (default: `inputs`)
|
39 |
+
- `min_sec`: Minimum duration of the sliced audio files in seconds (default: 2).
|
40 |
+
- `max_sec`: Maximum duration of the sliced audio files in seconds (default: 12).
|
41 |
+
- `--time_suffix`: Make the filename end with -start_ms-end_ms when saving wav.
|
42 |
+
|
43 |
+
### 1.2. Transcribe audio files
|
44 |
+
|
45 |
+
```bash
|
46 |
+
python transcribe.py --model_name <model_name>
|
47 |
+
```
|
48 |
+
Required:
|
49 |
+
- `model_name`: Name of the speaker (to be used as the name of the trained model).
|
50 |
+
|
51 |
+
Optional
|
52 |
+
- `--initial_prompt`: Initial prompt to use for the transcription (default value is specific to Japanese).
|
53 |
+
- `--device`: `cuda` or `cpu` (default: `cuda`).
|
54 |
+
- `--language`: `jp`, `en`, or `en` (default: `jp`).
|
55 |
+
- `--model`: Whisper model, default: `large-v3`
|
56 |
+
- `--compute_type`: default: `bfloat16`. Only used if not `--use_hf_whisper`.
|
57 |
+
- `--use_hf_whisper`: Use Hugging Face's whisper model instead of default faster-whisper (HF whisper is faster but requires more VRAM).
|
58 |
+
- `--batch_size`: Batch size (default: 16). Only used if `--use_hf_whisper`.
|
59 |
+
- `--num_beams`: Beam size (default: 1).
|
60 |
+
- `--no_repeat_ngram_size`: N-gram size for no repeat (default: 10).
|
61 |
+
|
62 |
+
## 2. Preprocess
|
63 |
+
|
64 |
+
```bash
|
65 |
+
python preprocess_all.py -m <model_name> [--use_jp_extra] [-b <batch_size>] [-e <epochs>] [-s <save_every_steps>] [--num_processes <num_processes>] [--normalize] [--trim] [--val_per_lang <val_per_lang>] [--log_interval <log_interval>] [--freeze_EN_bert] [--freeze_JP_bert] [--freeze_ZH_bert] [--freeze_style] [--freeze_decoder] [--yomi_error <yomi_error>]
|
66 |
+
```
|
67 |
+
|
68 |
+
Required:
|
69 |
+
- `model_name`: Name of the speaker (to be used as the name of the trained model).
|
70 |
+
|
71 |
+
Optional:
|
72 |
+
- `--batch_size`, `-b`: Batch size (default: 2).
|
73 |
+
- `--epochs`, `-e`: Number of epochs (default: 100).
|
74 |
+
- `--save_every_steps`, `-s`: Save every steps (default: 1000).
|
75 |
+
- `--num_processes`: Number of processes (default: half of the number of CPU cores).
|
76 |
+
- `--normalize`: Loudness normalize audio.
|
77 |
+
- `--trim`: Trim silence.
|
78 |
+
- `--freeze_EN_bert`: Freeze English BERT.
|
79 |
+
- `--freeze_JP_bert`: Freeze Japanese BERT.
|
80 |
+
- `--freeze_ZH_bert`: Freeze Chinese BERT.
|
81 |
+
- `--freeze_style`: Freeze style vector.
|
82 |
+
- `--freeze_decoder`: Freeze decoder.
|
83 |
+
- `--use_jp_extra`: Use JP-Extra model.
|
84 |
+
- `--val_per_lang`: Validation data per language (default: 0).
|
85 |
+
- `--log_interval`: Log interval (default: 200).
|
86 |
+
- `--yomi_error`: How to handle yomi errors (default: `raise`: raise an error after preprocessing all texts, `skip`: skip the texts with errors, `use`: use the texts with errors by ignoring unknown characters).
|
87 |
+
|
88 |
+
## 3. Train
|
89 |
+
|
90 |
+
Training settings are automatically loaded from the above process.
|
91 |
+
|
92 |
+
If NOT using JP-Extra model:
|
93 |
+
```bash
|
94 |
+
python train_ms.py [--repo_id <username>/<repo_name>]
|
95 |
+
```
|
96 |
+
|
97 |
+
If using JP-Extra model:
|
98 |
+
```bash
|
99 |
+
python train_ms_jp_extra.py [--repo_id <username>/<repo_name>] [--skip_default_style]
|
100 |
+
```
|
101 |
+
|
102 |
+
Optional:
|
103 |
+
- `--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.
|
104 |
+
- `--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).
|
docs/README_en.md
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This English README is for 1.x versions. WIP for 2.x versions.
|
2 |
+
|
3 |
+
# Style-Bert-VITS2
|
4 |
+
|
5 |
+
Bert-VITS2 with more controllable voice styles.
|
6 |
+
|
7 |
+
https://github.com/litagin02/Style-Bert-VITS2/assets/139731664/b907c1b8-43aa-46e6-b03f-f6362f5a5a1e
|
8 |
+
|
9 |
+
[Zenn Commentary Article (translated)](Style-Bert-VITS2_en.md) ([original](https://zenn.dev/litagin/articles/034819a5256ff4))
|
10 |
+
|
11 |
+
[](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
|
12 |
+
|
13 |
+
Online demo: https://huggingface.co/spaces/litagin/Style-Bert-VITS2-JVNV
|
14 |
+
|
15 |
+
This repository is based on [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2) v2.1, so many thanks to the original author!
|
16 |
+
|
17 |
+
- [Update History](docs/CHANGELOG.md)
|
18 |
+
|
19 |
+
**Overview**
|
20 |
+
|
21 |
+
- 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.
|
22 |
+
- 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: [](http://colab.research.google.com/github/litagin02/Style-Bert-VITS2/blob/master/colab.ipynb)
|
23 |
+
- If used only for voice synthesis, it can operate on CPU without a graphics card.
|
24 |
+
- Also includes an API server for integration with others (PR by [@darai0512](https://github.com/darai0512), thank you).
|
25 |
+
- 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.
|
26 |
+
|
27 |
+
|
28 |
+
## How to Use
|
29 |
+
|
30 |
+
<!-- For more details, please refer to [here](docs/tutorial.md). -->
|
31 |
+
|
32 |
+
### Operating Environment
|
33 |
+
|
34 |
+
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).
|
35 |
+
|
36 |
+
### Installation
|
37 |
+
|
38 |
+
#### For Those Unfamiliar with Git or Python
|
39 |
+
|
40 |
+
Assuming Windows:
|
41 |
+
|
42 |
+
1. Download and unzip [this zip file](https://github.com/litagin02/Style-Bert-VITS2/releases/download/1.3/Style-Bert-VITS2.zip).
|
43 |
+
- If you have a graphics card, double-click `Install-Style-Bert-VITS2.bat`.
|
44 |
+
- If you don't have a graphics card, double-click `Install-Style-Bert-VITS2-CPU.bat`.
|
45 |
+
2. Wait for the necessary environment to install automatically.
|
46 |
+
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.
|
47 |
+
|
48 |
+
For updates, please double-click `Update-Style-Bert-VITS2.bat`.
|
49 |
+
|
50 |
+
#### For Those Familiar with Git and Python
|
51 |
+
|
52 |
+
```bash
|
53 |
+
git clone https://github.com/litagin02/Style-Bert-VITS2.git
|
54 |
+
cd Style-Bert-VITS2
|
55 |
+
python -m venv venv
|
56 |
+
venv\Scripts\activate
|
57 |
+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
58 |
+
pip install -r requirements.txt
|
59 |
+
python initialize.py # Download necessary models and default TTS model
|
60 |
+
```
|
61 |
+
Don't forget the last step.
|
62 |
+
|
63 |
+
### Voice Synthesis
|
64 |
+
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.
|
65 |
+
|
66 |
+
The structure of the model files required for voice synthesis is as follows (you don't need to place them manually):
|
67 |
+
|
68 |
+
```
|
69 |
+
model_assets
|
70 |
+
├── your_model
|
71 |
+
│ ├── config.json
|
72 |
+
│ ├── your_model_file1.safetensors
|
73 |
+
│ ├── your_model_file2.safetensors
|
74 |
+
│ ├── ...
|
75 |
+
│ └── style_vectors.npy
|
76 |
+
└── another_model
|
77 |
+
├── ...
|
78 |
+
```
|
79 |
+
|
80 |
+
For inference, `config.json`, `*.safetensors`, and `style_vectors.npy` are necessary. If you want to share a model, please share these three files.
|
81 |
+
|
82 |
+
Among them, `style_vectors.npy` is a file necessary to control the style. By default, the average style "Neutral" is generated during training.
|
83 |
+
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).
|
84 |
+
|
85 |
+
### Training
|
86 |
+
|
87 |
+
Double-click Train.bat or run `python webui_train.py` to launch the WebUI.
|
88 |
+
|
89 |
+
### Generating Styles
|
90 |
+
For those who want to use styles other than the default "Neutral".
|
91 |
+
|
92 |
+
- Double-click `Style.bat` or run `python webui_style_vectors.py` to launch the WebUI.
|
93 |
+
- 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).
|
94 |
+
- For more details on the specifications of the style, please refer to [clustering.ipynb](../clustering.ipynb).
|
95 |
+
|
96 |
+
### Dataset Creation
|
97 |
+
|
98 |
+
- 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.
|
99 |
+
|
100 |
+
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.
|
101 |
+
|
102 |
+
Please experiment to see what kind of dataset is best.
|
103 |
+
|
104 |
+
### API Server
|
105 |
+
Run `python server_fastapi.py` in the constructed environment to launch the API server.
|
106 |
+
Please check the API specification after launching at `/docs`.
|
107 |
+
|
108 |
+
By default, CORS settings are allowed for all domains.
|
109 |
+
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).
|
110 |
+
|
111 |
+
### Merging
|
112 |
+
You can create a new model by mixing two models in terms of "voice", "emotional expression", and "tempo".
|
113 |
+
Double-click `Merge.bat` or run `python webui_merge.py` to launch the WebUI.
|
114 |
+
|
115 |
+
## Relation to Bert-VITS2 v2.1
|
116 |
+
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).
|
117 |
+
|
118 |
+
The differences are as follows:
|
119 |
+
|
120 |
+
- Like [EasyBertVits2](https://github.com/Zuntan03/EasyBertVits2), it is easy to use even for people who do not know Python or Git.
|
121 |
+
- 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)
|
122 |
+
- Removed vector quantization from embeddings and replaced it with just a fully connected layer.
|
123 |
+
- By creating a style vector file `style_vectors.npy`, you can generate voices using that style and continuously specify the strength of the effect.
|
124 |
+
- Various WebUIs created
|
125 |
+
- Support for bf16 training
|
126 |
+
- Support for safetensors format, defaulting to using safetensors
|
127 |
+
- Other minor bug fixes and refactoring
|
docs/Style-Bert-VITS2_en.md
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Announcements
|
2 |
+
|
3 |
+
* I uploaded a tutorial video explaining Style-Bert-VITS2, which can be found on [YouTube](https://www.youtube-nocookie.com/embed/aTUSzgDl1iY).
|
4 |
+
|
5 |
+
* I frequently visit the「AI声づくり研究会」 (AI Voice Creation Research Group) Discord server.
|
6 |
+
|
7 |
+
# Overview
|
8 |
+
|
9 |
+
On February 1, 2024, a Japanese-specialized version of the Chinese open-source text-to-speech (TTS) model Bert-VITS2, called [Bert-VITS2 JP-Extra](https://github.com/fishaudio/Bert-VITS2/releases/tag/JP-Exta), was released. My modified version, [Style-Bert-VITS2](https://github.com/litagin02/Style-Bert-VITS2), now supports the JP-Extra version as of February 3.
|
10 |
+
|
11 |
+
You can try out the model using the [online demo](https://huggingface.co/spaces/litagin/Style-Bert-VITS2-JVNV).
|
12 |
+
|
13 |
+
This version improves the naturalness of Japanese pronunciation, accent, and intonation, while reducing clarity issues and instability during training. If you only need Japanese TTS and don't require English or Chinese, using the JP-Extra version is highly recommended.
|
14 |
+
|
15 |
+
This article discusses the differences between the JP-Extra version and the [previous 2.1-2.3 structures](https://zenn.dev/litagin/articles/8c6edcf6b6fcd6), as well as how Style-Bert-VITS2 further modifies the model.
|
16 |
+
|
17 |
+
# Disclaimer
|
18 |
+
|
19 |
+
I have not formally studied machine learning, voice AI, or Japanese language processing, so there may be inaccuracies in the article.
|
20 |
+
|
21 |
+
# Short Summary
|
22 |
+
|
23 |
+
Compared to other versions, (Style-)Bert-VITS2 JP-Extra:
|
24 |
+
|
25 |
+
- Fixes bugs in the Japanese reading and accent acquisition parts of the original version (thanks to my contributions ✌)
|
26 |
+
- Increases the amount of Japanese training data used for the pre-trained model (approximately 800 hours for Japanese only)
|
27 |
+
- Removes Chinese and English components to focus on Japanese performance
|
28 |
+
- Implements voice control using prompts with CLAP, as in version 2.2 (although it doesn't seem very practical, similar to 2.2)
|
29 |
+
- Uses the new WavLM-based discriminator from version 2.3 to improve naturalness
|
30 |
+
- Removes the duration discriminator to avoid unstable phoneme intervals, as seen in version 2.3
|
31 |
+
- In Style-Bert-VITS2, the seemingly ineffective CLAP-based emotion embedding is removed and replaced with a simple fully connected layer for style embedding, as in the previous version
|
32 |
+
- Style-Bert-VITS2 also allows for (some) manual control of accents
|
33 |
+
|
34 |
+
These changes significantly improve the naturalness of Japanese pronunciation and accents, increase clarity, and reduce the impression of "Japanese spoken by a foreigner" that was present in earlier versions.
|
35 |
+
|
36 |
+
Below I will write a little about these changes from a layman's perspective.
|
37 |
+
|
38 |
+
# Increase in Japanese Training Data
|
39 |
+
|
40 |
+
According to the [Bert-VITS2 JP-Extra release page](https://github.com/fishaudio/Bert-VITS2/releases/tag/JP-Exta);
|
41 |
+
|
42 |
+
> 3. "the amount of Japanese training data has been increased several times, now up to approximately 800 hours for a single language"
|
43 |
+
|
44 |
+
The increase in data (along with the fixes to Japanese processing bugs) may contribute more to the improvement in naturalness than the model structure refinements, although this is not certain without further experimentation.
|
45 |
+
|
46 |
+
# Japanese Language Processing
|
47 |
+
|
48 |
+
The following section is not directly related to the main topic of model structure, so feel free to skip it if you are not interested.
|
49 |
+
|
50 |
+
In a previous article, I mentioned that the original version had bugs in the Japanese processing part, and that Style-Bert-VITS2 fixed them. The current (Style-)Bert-VITS2 JP-Extra incorporates those fixes. Here, I will explain precisely what kind of processing is performed on Japanese text.
|
51 |
+
|
52 |
+
## Overview of Japanese Processing in Japanese TTS Models
|
53 |
+
|
54 |
+
In Japanese TTS, the input Japanese text is typically converted into a phoneme sequence, a process called grapheme-to-phoneme (g2p). Both during training and inference, the phoneme sequence obtained from the g2p process is fed into the model as input (in addition to the original Japanese text via BERT, which is a unique feature of Bert-VITS2).
|
55 |
+
|
56 |
+
## Example
|
57 |
+
|
58 |
+
The [pyopenjtalk](https://github.com/r9y9/pyopenjtalk) library, which has become a de facto standard for Japanese phoneme processing and is used in Bert-VITS2, provides a g2p function. For example:
|
59 |
+
|
60 |
+
```python
|
61 |
+
>>> import pyopenjtalk
|
62 |
+
>>> pyopenjtalk.g2p("おはよう!元気ですか?")
|
63 |
+
'o h a y o o pau g e N k i d e s U k a'
|
64 |
+
```
|
65 |
+
|
66 |
+
The function returns a space-separated list of phonemes for the input text.
|
67 |
+
|
68 |
+
## Limitations of pyopenjtalk's Default g2p
|
69 |
+
|
70 |
+
While `pyopenjtalk.g2p` is convenient, it has some limitations:
|
71 |
+
|
72 |
+
1. It only returns a simple phoneme sequence without any accent information.
|
73 |
+
2. All punctuation marks and symbols like "!?" in the input text are treated as pause phonemes (`pau`), so "私は……そう思う……。" and "私は!!!!そう思う!!!" are not distinguished.
|
74 |
+
|
75 |
+
### g2p Considering Accents
|
76 |
+
|
77 |
+
Accents are an important issue in Japanese TTS. Unlike English or Chinese, each word in Japanese has a correct accent, and incorrect accents can cause significant unnaturalness. Therefore, it is desirable to correctly learn the accent information in addition to the phonemes and, if possible, to enable manual accent specification for TTS.
|
78 |
+
|
79 |
+
There are various approaches to incorporating accent information into the model. For example, [ESPNet](https://github.com/espnet/espnet), which allows for various voice-related training tasks, provides the [following g2p functions](https://github.com/espnet/espnet/blob/59733c2f1a962575667f6887e87fcdf04e06afc3/egs2/jvs/tts1/run.sh#L29-L49) for Japanese:
|
80 |
+
|
81 |
+
- `pyopenjtalk`: Uses the default `pyopenjtalk.g2p` function without accent information
|
82 |
+
- `pyopenjtalk_accent`: Inserts accent information using `0` for low and `1` for high pitch after each phoneme
|
83 |
+
- `pyopenjtalk_prosody`: Inserts `[` for pitch rise and `]` for pitch fall as part of the phoneme symbols
|
84 |
+
- `pyopenjtalk_kana`: Outputs katakana instead of phonemes
|
85 |
+
- `pyopenjtalk_phone`: Outputs phonemes with stress and tone marks
|
86 |
+
|
87 |
+
The choice of which g2p function to use varies among libraries, and it is unclear which one is the most common. For example, [COEIROINK](https://coeiroink.com/) uses `pyopenjtalk_prosody`.
|
88 |
+
|
89 |
+
However, **all of these g2p functions have the second limitation mentioned above, where the type and number of symbols in the input text are not distinguished**. We desire the model to read "私は……そう思う……。" with a lack of confidence and "私は!!!!そう思う!!!" as shouting loudly, but this is not possible with these functions.
|
90 |
+
|
91 |
+
In Bert-VITS2, accent information is fed into the model separately from the phoneme sequence under the name `tones`. This assigns the numbers 0 or 1 to each phoneme in the phoneme sequence. For Japanese, it looks like this:
|
92 |
+
|
93 |
+
```
|
94 |
+
おはよう!!!ございます?
|
95 |
+
→ (o: 0), (h: 1), (a: 1), (y: 1), (o: 1), (o: 1), (!, 0), (!, 0), (!, 0), (g: 0) (o: 0), (z: 1) (a: 1), (i: 1), (m: 1), (a: 1), (s: 0), (u: 0), (?, 0)
|
96 |
+
```
|
97 |
+
|
98 |
+
The low (0) and high (1) values are assigned to each phoneme, and this sequence of values is fed into the model separately from the phoneme sequence. Furthermore, as in the example above, **the symbols in the text are treated as phonemes themselves, distinguishing their type and number**.
|
99 |
+
|
100 |
+
Implementing such a g2p function might be easy for experts in the Japanese TTS field, but lacking such knowledge, I took the following approach:
|
101 |
+
|
102 |
+
1. First, obtain a phoneme sequence with pitch rise and fall symbols using `pyopenjtalk_prosody` from ESPNet (however, the information about symbols like "!" and "…" is lost)
|
103 |
+
2. Use this to create a list of phoneme-accent pairs with the symbols completely removed
|
104 |
+
3. Separately create a phoneme sequence (without accent information) that includes the symbols
|
105 |
+
4. Combine the two results to obtain the desired output
|
106 |
+
|
107 |
+
It might be possible to perform these operations using `pyopenjtalk` alone, but there are some difficulties:
|
108 |
+
|
109 |
+
- In pyopenjtalk (OpenJTalk), obtaining accent information seems to always require extracting full context labels from the text (`pyopenjtalk.extract_fullcontext`), but the information about the type and number of symbols in the text is already lost at the full context label stage (so it is fundamentally impossible to obtain the desired result by parsing the full context labels)
|
110 |
+
|
111 |
+
On the other hand, for step 3 above, the `pyopenjtalk.run_frontend` function obtains the reading in `pron` while preserving the type and number of symbols, as follows:
|
112 |
+
|
113 |
+
As you can see, the `pron` part of the `pyopenjtalk.run_frontend` output preserves the type and number of symbols, so converting this to a phoneme sequence would accomplish step 3.
|
114 |
+
|
115 |
+
Then, it's just a matter of writing processing code to combine the two results.
|
116 |
+
|
117 |
+
For more details (and for my own reference), please refer to the well-commented source code.
|
118 |
+
|
119 |
+
I actively welcome suggestions on how to simplify this process.
|
120 |
+
|
121 |
+
## Previously Existing Bugs
|
122 |
+
|
123 |
+
Previous versions of Bert-VITS2 did not use the above method and had the following bugs:
|
124 |
+
|
125 |
+
1. When converting the reading result of `pyopenjtalk.run_frontend` to a phoneme list, the katakana reading was further processed by `pyopenjtalk.g2p`, causing issues.
|
126 |
+
2. The accent acquisition method was inaccurate, and the information was reset at word boundaries. For example, the correct accent for "私は思う" is "ワ➚タシワ オ➚モ➘ウ", but it became "ワ➚タシ➘ワ オ➚モ➘ウ" (due to the separate processing of "私" and "は").
|
127 |
+
|
128 |
+
Regarding the first bug, further applying `pyopenjtalk.g2p` to the reading "シャリョオ" of "車両" results in "シャリヨオ":
|
129 |
+
|
130 |
+
This behavior of `pyopenjtalk.g2p` (whether intentional or a bug) affected the subsequent accent processing, causing all accents after words like "車両" or "思う" to become "0".
|
131 |
+
|
132 |
+
(I am unsure whether this behavior of `pyopenjtalk.g2p` is intended or a bug)
|
133 |
+
|
134 |
+
# Changes in Model Structure
|
135 |
+
|
136 |
+
The main idea of "inputting not only the phoneme sequence but also semantic information obtained from BERT to enable content-aware reading" remains unchanged. However, there are some differences between the JP-Extra version and the existing 2.1-2.3 models, which will be discussed in this section.
|
137 |
+
|
138 |
+
## Basic Framework
|
139 |
+
|
140 |
+
Please refer to the [previous article](https://zenn.dev/litagin/articles/7179bb40f1f3a1).
|
141 |
+
|
142 |
+
To summarize, the voice generation (generator) part of (Style-)Bert-VITS2 consists of the following components:
|
143 |
+
|
144 |
+
- TextEncoder (receives text and returns various information)
|
145 |
+
- DurationPredictor (returns phoneme intervals, i.e., the duration of each phoneme)
|
146 |
+
- StochasticDurationPredictor (adds randomness to DurationPredictor?)
|
147 |
+
- Flow (contains voice tone information, especially pitch)
|
148 |
+
- Decoder (synthesizes the final voice output using various information; also contains voice tone information)
|
149 |
+
|
150 |
+
Furthermore, since the model uses a GAN for training, both the Generator (voice generation) and the Discriminator (distinguishes between real and generated voices) are trained. The following components correspond to the files saved during actual training:
|
151 |
+
|
152 |
+
- Generator: Has the above structure and generates voice from text. Saved in the `G_1000.pth` file. Only this is required for inference.
|
153 |
+
- MultiPeriodDiscriminator: I lack the knowledge to explain this. Saved in the `D_1000.pth` file. It is the main discriminator and is apparently used in HiFi-GAN and other models.
|
154 |
+
- DurationDiscriminator: Apparently a discriminator for phoneme intervals (output of DurationPredictor, etc). Saved in the `DUR_1000.pth` file.
|
155 |
+
- **WavLMDiscriminator**: Will be discussed in more detail later. Saved in the `WD_1000.pth` file. It seems to be a discriminator using the [WavLM](https://arxiv.org/abs/2110.13900) SSL model for voice.
|
156 |
+
|
157 |
+
The original JP-Extra version roughly follows the structure of Bert-VITS2 ver 2.3, with the addition of output control using CLAP prompts from ver 2.2.
|
158 |
+
|
159 |
+
The important structural points are as follows:
|
160 |
+
|
161 |
+
1. Use of WavLMDiscriminator introduced in ver 2.3
|
162 |
+
2. Removal of DurationDiscriminator
|
163 |
+
3. Increase of `gin_channels` parameter from 256 in 2.1 and 2.2 to 512, as in 2.3
|
164 |
+
4. Voice tone control using CLAP prompts
|
165 |
+
|
166 |
+
### 1. WavLMDiscriminator
|
167 |
+
|
168 |
+
I the knowledge and ability to provide a full explanation, so only the understood points will be discussed.
|
169 |
+
|
170 |
+
In the machine learning field, **SSL (Self-Supervised Learning) models**, which are trained on large amounts of unlabeled data, seem to be useful. These models are used as a base for downstream tasks.
|
171 |
+
|
172 |
+
In the voice field, the following models might be well-known:
|
173 |
+
|
174 |
+
- [HuBERT](https://arxiv.org/abs/2106.07447)
|
175 |
+
- [ContentVec](https://arxiv.org/abs/2204.09224)
|
176 |
+
- [wav2vec 2.0](https://arxiv.org/abs/2006.11477)
|
177 |
+
- [WavLM](https://arxiv.org/abs/2110.13900)
|
178 |
+
|
179 |
+
The **WavLM** model, specifically [microsoft/wavlm-base-plus](https://huggingface.co/microsoft/wavlm-base-plus), was introduced in Bert-VITS2 ver 2.3 and is also used in the JP-Extra version.
|
180 |
+
|
181 |
+
Although I do not fully understand the details, using the WavLM SSL model as a discriminator seems to improve the quality of the discriminator and, consequently, the quality of the generated voice. The `WD_*` files that started appearing in pre-trained models and during training in ver 2.3 and (Style-)Bert-VITS2 JP-Extra correspond to this model.
|
182 |
+
|
183 |
+
### 2. Removal of DurationDiscriminator
|
184 |
+
|
185 |
+
(Style-)Bert-VITS2 had been using DurationDiscriminator for some time, but since ver 2.3 (possibly due to compatibility with WavLMDiscriminator?), there have been issues with phoneme intervals becoming slightly unstable (sounding stretched or not stabilizing during training).
|
186 |
+
|
187 |
+
Considering this, the JP-Extra version does not use this component (so the `DUR_0` pre-trained model is no longer required).
|
188 |
+
|
189 |
+
As a result, you might get a slight impression of faster speech, but overall, the phoneme intervals seem to have settled down. The presence or absence of this DurationDiscriminator can be easily changed in the settings, so experimenting with it might yield some insights.
|
190 |
+
|
191 |
+
### 3. Addition of gin_channels
|
192 |
+
|
193 |
+
I can only provide impressions on this change, which was made in the original ver 2.3. There is a parameter called `gin_channels` that collectively determines the dimensions of the hidden layers in the model, and it was increased from 256 to 512.
|
194 |
+
|
195 |
+
In the previous comments on Bert-VITS2 2.3, I had the impression that increasing this value might have added a slight inability to fully train the model. However, considering the success of the JP-Extra version (which may have benefited from an increase in the amount of data used for pre-training), increasing the dimensions might have been a good change in the end (although this cannot be stated with certainty without experimenting with 256).
|
196 |
+
|
197 |
+
### 4. CLAP
|
198 |
+
|
199 |
+
This feature was introduced in the original Bert-VITS2 ver 2.2 (and removed in ver 2.3). It uses the [CLAP](https://huggingface.co/laion/clap-htsat-fused) model, which is trained on audio-text pairs, to attempt to control the output voice using text prompts (e.g., `Happy`).
|
200 |
+
|
201 |
+
Specifically, an embedding related to the CLAP model (which can extract feature vectors from both audio and text) is added to the TextEncoder part.
|
202 |
+
|
203 |
+
To be honest, while this may have been effective at the pre-trained model level, its effect seems to almost disappear when fine-tuning the model for practical use, and voice control using prompts is hardly possible, based on my experience.
|
204 |
+
|
205 |
+
# Conclusion
|
206 |
+
|
207 |
+
I encourage everyone to use Style-Bert-VITS2! It comes with tools for creating datasets and does not require Python environment setup for installation. As long as you have a GPU, you can easily train the model. Let's create our own tts models!
|