From f58fb45818d22d867869fc50ddb8cea947a85f2e Mon Sep 17 00:00:00 2001 From: Artrajz <969242373@qq.com> Date: Sun, 5 Nov 2023 18:15:33 +0800 Subject: [PATCH] Update docs --- README.md | 285 +++++++++++++++++++++++++------------------------ README_zh.md | 293 +++++++++++++++++++++++++++------------------------ 2 files changed, 301 insertions(+), 277 deletions(-) diff --git a/README.md b/README.md index 901940d..712db22 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ - [x] SSML (Speech Synthesis Markup Language) work in progress... -## demo +## Online Demo -[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Artrajz/vits-simple-api) +[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Artrajz/vits-simple-api) Thanks to Hugging Face! Please note that different IDs may support different languages.[speakers](https://artrajz-vits-simple-api.hf.space/voice/speakers) @@ -45,177 +45,135 @@ Please note that different IDs may support different languages.[speakers](https: https://user-images.githubusercontent.com/73542220/237995061-c1f25b4e-dd86-438a-9363-4bb1fe65b425.mov -# Deploy +# Deployment -## Docker(Recommended for Linux) +There are two deployment options to choose from. Regardless of the option you select, you'll need to import the model after deployment to use the application. -### Docker image pull script +## Docker Deployment (Recommended for Linux) -``` +### Step 1: Pull the Docker Image + +Run the following command to pull the Docker image. Follow the prompts in the script to choose the necessary files to download and pull the image: + +```bash bash -c "$(wget -O- https://raw.githubusercontent.com/Artrajz/vits-simple-api/main/vits-simple-api-installer-latest.sh)" ``` -- The platforms currently supported by Docker images are `linux/amd64` and `linux/arm64`.(arm64 only has a CPU version) -- After a successful pull, the vits model needs to be imported before use. Please follow the steps below to import the model. +The default paths for project configuration files and model folders are `/usr/local/vits-simple-api/`. -### Download VITS model +### Step 2: Start -Put the model into `/usr/local/vits-simple-api/Model` +Run the following command to start the container: -
Folder structure

-│  hubert-soft-0d54a1f4.pt
-│  model.onnx
-│  model.yaml
-│
-├─g
-│      config.json
-│      G_953000.pth
-│
-├─louise
-│      360_epochs.pth
-│      config.json
-│
-├─Nene_Nanami_Rong_Tang
-│      1374_epochs.pth
-│      config.json
-│
-├─Zero_no_tsukaima
-│       1158_epochs.pth
-│       config.json
-│
-└─npy
-       25ecb3f6-f968-11ed-b094-e0d4e84af078.npy
-       all_emotions.npy
-
+```bash +docker-compose up -d +``` +### Image Update +To update the image, run the following commands: +```bash +docker-compose pull +``` +Then, restart the container: -### Modify model path +```bash +docker-compose up -d +``` -Modify in `/usr/local/vits-simple-api/config.py` +## Virtual Environment Deployment -
config.py

-# Fill in the model path here
-MODEL_LIST = [
-    # VITS
-    [ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/1374_epochs.pth", ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/config.json"],
-    [ABS_PATH + "/Model/Zero_no_tsukaima/1158_epochs.pth", ABS_PATH + "/Model/Zero_no_tsukaima/config.json"],
-    [ABS_PATH + "/Model/g/G_953000.pth", ABS_PATH + "/Model/g/config.json"],
-    # HuBert-VITS (Need to configure HUBERT_SOFT_MODEL)
-    [ABS_PATH + "/Model/louise/360_epochs.pth", ABS_PATH + "/Model/louise/config.json"],
-    # W2V2-VITS (Need to configure DIMENSIONAL_EMOTION_NPY)
-    [ABS_PATH + "/Model/w2v2-vits/1026_epochs.pth", ABS_PATH + "/Model/w2v2-vits/config.json"],
-]
-# hubert-vits: hubert soft model
-HUBERT_SOFT_MODEL = ABS_PATH + "/Model/hubert-soft-0d54a1f4.pt"
-# w2v2-vits: Dimensional emotion npy file
-# load single npy: ABS_PATH+"/all_emotions.npy
-# load mutiple npy: [ABS_PATH + "/emotions1.npy", ABS_PATH + "/emotions2.npy"]
-# load mutiple npy from folder: ABS_PATH + "/Model/npy"
-DIMENSIONAL_EMOTION_NPY = ABS_PATH + "/Model/npy"
-# w2v2-vits: Need to have both `model.onnx` and `model.yaml` files in the same path.
-DIMENSIONAL_EMOTION_MODEL = ABS_PATH + "/Model/model.yaml"
-
+### Step 1: Clone the Project +Clone the project repository using the following command: +```bash +git clone https://github.com/Artrajz/vits-simple-api.git +``` +### Step 2: Install Python Dependencies +It's recommended to use a Python virtual environment. Run the following command to install the required Python dependencies: -### Startup +```bash +pip install -r requirements.txt +``` -`docker compose up -d` +### Step 3: Start -Or execute the pull script again +Run the following command to start the program: -### Image update +```bash +python app.py +``` -Run the docker image pull script again +## Windows Quick Deployment Package -## Virtual environment deployment +### Step 1: Download and Extract the Deployment Package -### Clone +Go to the [releases page](https://github.com/Artrajz/vits-simple-api/releases) and download the latest deployment package. Extract the downloaded files. -`git clone https://github.com/Artrajz/vits-simple-api.git` +### Step 2: Start -### Download python dependencies +Run `start.bat` to launch the program. -A python virtual environment is recommended +## Model Loading -`pip install -r requirements.txt` +### Step 1: Download VITS Models +Download the VITS model files and place them in the Model directory. -Fasttext may not be installed on windows, you can install it with the following command,or download wheels [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext) +### Step 2: Loading Models + +If you are starting for the first time, modify the default model path configuration in the config.py file (optional). + +After the first startup, a config.yml configuration file will be generated. You can either modify the model_list in the configuration file or make changes through the admin backend in the browser (not yet implemented). + +You can specify the model paths using either absolute or relative paths, where relative paths are considered from the Model folder in the project's root directory. + +For example, if the Model folder contains the following files: ``` -# python3.10 win_amd64 -pip install https://github.com/Artrajz/archived/raw/main/fasttext/fasttext-0.9.2-cp310-cp310-win_amd64.whl +├─model1 +│ │─G_1000.pth +│ └─config.json +└─model2 + │─G_1000.pth + └─config.json +``` + +You have multiple options for specifying the paths based on your preference. + +Option 1: + +``` +'model_config': + 'model_list': + - - model1/G_1000.pth + - model1/config.json + - - model2/G_1000.pth + - model2/config.json +``` + +Option 2: + +``` +'model_config': + 'model_list': + - [model1/G_1000.pth, model1/config.json] + - [model2/G_1000.pth, model2/config.json] ``` -### Download VITS model - -Put the model into `/path/to/vits-simple-api/Model` - -
Folder structure

-│  hubert-soft-0d54a1f4.pt
-│  model.onnx
-│  model.yaml
-│
-├─g
-│      config.json
-│      G_953000.pth
-│
-├─louise
-│      360_epochs.pth
-│      config.json
-│
-├─Nene_Nanami_Rong_Tang
-│      1374_epochs.pth
-│      config.json
-│
-├─Zero_no_tsukaima
-│       1158_epochs.pth
-│       config.json
-│
-└─npy
-       25ecb3f6-f968-11ed-b094-e0d4e84af078.npy
-       all_emotions.npy
-
- - - -### Modify model path - -Modify in `/path/to/vits-simple-api/config.py` - -
config.py

-# Fill in the model path here
-MODEL_LIST = [
-    # VITS
-    [ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/1374_epochs.pth", ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/config.json"],
-    [ABS_PATH + "/Model/Zero_no_tsukaima/1158_epochs.pth", ABS_PATH + "/Model/Zero_no_tsukaima/config.json"],
-    [ABS_PATH + "/Model/g/G_953000.pth", ABS_PATH + "/Model/g/config.json"],
-    # HuBert-VITS (Need to configure HUBERT_SOFT_MODEL)
-    [ABS_PATH + "/Model/louise/360_epochs.pth", ABS_PATH + "/Model/louise/config.json"],
-    # W2V2-VITS (Need to configure DIMENSIONAL_EMOTION_NPY)
-    [ABS_PATH + "/Model/w2v2-vits/1026_epochs.pth", ABS_PATH + "/Model/w2v2-vits/config.json"],
-]
-# hubert-vits: hubert soft model
-HUBERT_SOFT_MODEL = ABS_PATH + "/Model/hubert-soft-0d54a1f4.pt"
-# w2v2-vits: Dimensional emotion npy file
-# load single npy: ABS_PATH+"/all_emotions.npy
-# load mutiple npy: [ABS_PATH + "/emotions1.npy", ABS_PATH + "/emotions2.npy"]
-# load mutiple npy from folder: ABS_PATH + "/Model/npy"
-DIMENSIONAL_EMOTION_NPY = ABS_PATH + "/Model/npy"
-# w2v2-vits: Need to have both `model.onnx` and `model.yaml` files in the same path.
-DIMENSIONAL_EMOTION_MODEL = ABS_PATH + "/Model/model.yaml"
-
- - - -### Startup - -`python app.py` +Option 3: + +``` +'model_config': + 'model_list': [ + [model1/G_1000.pth, model1/config.json], + [model2/G_1000.pth, model2/config.json], + ] +``` # GPU accelerated @@ -236,14 +194,59 @@ pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/w ## Linux The installation process is similar, but I don't have the environment to test it. -# Dependency Installation Issues +# Disable the Admin Backend + +The admin backend allows loading and unloading models, and while it has login authentication, for added security, you can disable the admin backend in the `config.yml`: + +```yaml +'IS_ADMIN_ENABLED': !!bool 'false' +``` + +This extra measure helps ensure absolute security when making the admin backend inaccessible to the public network. + +# Frequently Asked Questions + +## Installation Issues with fastText Dependency + +Fasttext may not be installed on windows, you can install it with the following command,or download wheels [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext) + +```bash +# For Python 3.10 on win_amd64 +pip install https://github.com/Artrajz/archived/raw/main/fasttext/fasttext-0.9.2-cp310-cp310-win_amd64.whl +``` -Since pypi.org does not have the `pyopenjtalk` whl file, it usually needs to be installed from the source code. This process might be troublesome for some people. Therefore, you can also use the whl I built for installation. +or +```bash +pip install fasttext -i https://pypi.artrajz.cn/simple ``` + +## Installation Issues with pyopenjtalk Dependency + +Since pypi.org does not provide a wheel file for pyopenjtalk, you often need to install it from the source code. This process might be cumbersome for some users, so you can also install it using a pre-built wheel as follows: + +```bash pip install pyopenjtalk -i https://pypi.artrajz.cn/simple ``` + + +## Bert-VITS2 Version Compatibility + +To ensure compatibility with the Bert-VITS2 model, modify the config.json file by adding a version parameter "version": "x.x.x". For instance, if the model version is 1.0.1, the configuration file should be written as: + +```json +{ + "version": "1.0.1", + "train": { + "log_interval": 10, + "eval_interval": 100, + "seed": 52, + ... +``` + +​ + # API ## GET @@ -434,3 +437,7 @@ Learning and communication,now there is only Chinese [QQ group](https://qm.qq.co - vits_chinese:https://github.com/PlayVoice/vits_chinese - Bert_VITS2:https://github.com/fishaudio/Bert-VITS2 +# Thank You to All Contributors + + + diff --git a/README_zh.md b/README_zh.md index cc95835..43f78c3 100644 --- a/README_zh.md +++ b/README_zh.md @@ -32,9 +32,9 @@ - [x] SSML语音合成标记语言(完善中...) -## demo +## 在线demo -[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Artrajz/vits-simple-api) +[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Artrajz/vits-simple-api) 感谢hugging face喵 注意不同的id支持的语言可能有所不同。[speakers](https://artrajz-vits-simple-api.hf.space/voice/speakers) @@ -49,161 +49,134 @@ https://user-images.githubusercontent.com/73542220/237995061-c1f25b4e-dd86-438a- # 部署 +有两种部署方式可供选择。不论你选择哪一种,完成部署后都需要导入模型才能使用。 + ## Docker部署(Linux推荐) -### 镜像拉取脚本 +### 步骤1: 镜像拉取 -``` +运行以下命令以拉取 Docker 镜像,根据脚本中的提示选择需要下载的必要文件和拉取镜像: + +```bash bash -c "$(wget -O- https://raw.githubusercontent.com/Artrajz/vits-simple-api/main/vits-simple-api-installer-latest.sh)" ``` -- 目前docker镜像支持的平台`linux/amd64,linux/arm64`(arm64仅有CPU版本) -- 在拉取完成后,需要导入VITS模型才能使用,请根据以下步骤导入模型。 - -### 下载VITS模型 - -将模型放入`/usr/local/vits-simple-api/Model` - -
Folder structure

-│  hubert-soft-0d54a1f4.pt
-│  model.onnx
-│  model.yaml
-├─g
-│      config.json
-│      G_953000.pth
-│
-├─louise
-│      360_epochs.pth
-│      config.json
-│
-├─Nene_Nanami_Rong_Tang
-│      1374_epochs.pth
-│      config.json
-│
-├─Zero_no_tsukaima
-│       1158_epochs.pth
-│       config.json
-│
-└─npy
-       25ecb3f6-f968-11ed-b094-e0d4e84af078.npy
-       all_emotions.npy
-
- - - -### 修改模型路径 - -Modify in `/usr/local/vits-simple-api/config.py` - -
config.py

-# 在此填写模型路径
-MODEL_LIST = [
-    # VITS
-    [ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/1374_epochs.pth", ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/config.json"],
-    [ABS_PATH + "/Model/Zero_no_tsukaima/1158_epochs.pth", ABS_PATH + "/Model/Zero_no_tsukaima/config.json"],
-    [ABS_PATH + "/Model/g/G_953000.pth", ABS_PATH + "/Model/g/config.json"],
-    # HuBert-VITS (Need to configure HUBERT_SOFT_MODEL)
-    [ABS_PATH + "/Model/louise/360_epochs.pth", ABS_PATH + "/Model/louise/config.json"],
-    # W2V2-VITS (Need to configure DIMENSIONAL_EMOTION_NPY)
-    [ABS_PATH + "/Model/w2v2-vits/1026_epochs.pth", ABS_PATH + "/Model/w2v2-vits/config.json"],
-]
-# hubert-vits: hubert soft 编码器
-HUBERT_SOFT_MODEL = ABS_PATH + "/Model/hubert-soft-0d54a1f4.pt"
-# w2v2-vits: Dimensional emotion npy file
-# 加载单独的npy: ABS_PATH+"/all_emotions.npy
-# 加载多个npy: [ABS_PATH + "/emotions1.npy", ABS_PATH + "/emotions2.npy"]
-# 从文件夹里加载npy: ABS_PATH + "/Model/npy"
-DIMENSIONAL_EMOTION_NPY = ABS_PATH + "/Model/npy"
-# w2v2-vits: 需要在同一路径下有model.onnx和model.yaml
-DIMENSIONAL_EMOTION_MODEL = ABS_PATH + "/Model/model.yaml"
-
- - - -### 启动 - -`docker compose up -d` - -或者重新执行拉取脚本 +项目配置文件以及模型文件夹的默认路径为`/usr/local/vits-simple-api/` + +### 步骤2: 启动 + +运行以下命令启动容器: + +```bash +docker-compose up -d +``` ### 镜像更新 -重新执行docker镜像拉取脚本即可 +运行以下命令更新镜像: + +```bash +docker-compose pull +``` + +重新启动容器: + +```bash +docker-compose up -d +``` ## 虚拟环境部署 -### Clone +### 步骤1: 克隆项目 + +使用以下命令克隆项目仓库: -`git clone https://github.com/Artrajz/vits-simple-api.git` +```bash +git clone https://github.com/Artrajz/vits-simple-api.git +``` + +### 步骤2: 下载 Python 依赖 -### 下载python依赖 +推荐使用 Python 虚拟环境。运行以下命令安装项目所需的 Python 依赖: -推荐使用python的虚拟环境 +```bash +pip install -r requirements.txt +``` -`pip install -r requirements.txt` +### 步骤3: 启动 -windows下可能安装不了fasttext,可以用以下命令安装,附[wheels下载地址](https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext) +运行以下命令启动程序: +```bash +python app.py ``` -# python3.10 win_amd64 -pip install https://github.com/Artrajz/archived/raw/main/fasttext/fasttext-0.9.2-cp310-cp310-win_amd64.whl + +## Windows快速部署包 + +### 步骤1:下载并解压部署包 + +进入[releases页面](https://github.com/Artrajz/vits-simple-api/releases)下载并解压最新的部署包 + +### 步骤2:启动 + +运行start.bat启动程序 + +## 模型加载 + +### 步骤1: 下载 VITS 模型 + +将 VITS 模型文件下载并放入 `Model` 目录。 + +### 步骤2: 加载模型 + +如果是首次启动,在 `config.py` 文件中修改默认模型路径的配置。(非必须) + +首次启动之后会生成一个config.yml配置文件,可以修改配置文件中的model_list或者在浏览器中进入管理员后台进行修改(暂未实现) + +路径可填绝对路径或相对路径,相对路径则是从项目根目录中的Model文件夹开头。 + +比如Model文件夹中如下文件有 + +``` +├─model1 +│ │─G_1000.pth +│ └─config.json +└─model2 + │─G_1000.pth + └─config.json ``` -### 下载VITS模型 - -将模型放入 `/path/to/vits-simple-api/Model` - -
文件夹结构

-├─g
-│      config.json
-│      G_953000.pth
-│
-├─louise
-│      360_epochs.pth
-│      config.json
-│      hubert-soft-0d54a1f4.pt
-│
-├─Nene_Nanami_Rong_Tang
-│      1374_epochs.pth
-│      config.json
-│
-└─Zero_no_tsukaima
-        1158_epochs.pth
-        config.json
-
- -### 修改模型路径 - -在 `/path/to/vits-simple-api/config.py` 修改 - -
config.py

-# 在此填写模型路径
-MODEL_LIST = [
-    # VITS
-    [ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/1374_epochs.pth", ABS_PATH + "/Model/Nene_Nanami_Rong_Tang/config.json"],
-    [ABS_PATH + "/Model/Zero_no_tsukaima/1158_epochs.pth", ABS_PATH + "/Model/Zero_no_tsukaima/config.json"],
-    [ABS_PATH + "/Model/g/G_953000.pth", ABS_PATH + "/Model/g/config.json"],
-    # HuBert-VITS (Need to configure HUBERT_SOFT_MODEL)
-    [ABS_PATH + "/Model/louise/360_epochs.pth", ABS_PATH + "/Model/louise/config.json"],
-    # W2V2-VITS (Need to configure DIMENSIONAL_EMOTION_NPY)
-    [ABS_PATH + "/Model/w2v2-vits/1026_epochs.pth", ABS_PATH + "/Model/w2v2-vits/config.json"],
-]
-# hubert-vits: hubert soft 编码器
-HUBERT_SOFT_MODEL = ABS_PATH + "/Model/hubert-soft-0d54a1f4.pt"
-# w2v2-vits: Dimensional emotion npy file
-# 加载单独的npy: ABS_PATH+"/all_emotions.npy
-# 加载多个npy: [ABS_PATH + "/emotions1.npy", ABS_PATH + "/emotions2.npy"]
-# 从文件夹里加载npy: ABS_PATH + "/Model/npy"
-DIMENSIONAL_EMOTION_NPY = ABS_PATH + "/Model/npy"
-# w2v2-vits: 需要在同一路径下有model.onnx和model.yaml
-DIMENSIONAL_EMOTION_MODEL = ABS_PATH + "/Model/model.yaml"
-
- - - -### 启动 - -`python app.py` +有多种可选的填法,按个人喜好选择 + +填法1 + +```yaml +'model_config': + 'model_list': + - - model1/G_1000.pth + - model1/config.json + - - model2/G_1000.pth + - model2/config.json +``` + +填法2 + +```yaml +'model_config': + 'model_list': + - [model1/G_1000.pth, model1/config.json] + - [model2/G_1000.pth, model2/config.json] +``` + +填法3 + +```yaml +'model_config': + 'model_list': [ + [model1/G_1000.pth, model1/config.json], + [model2/G_1000.pth, model2/config.json], + ] +``` # GPU 加速 @@ -229,9 +202,33 @@ pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/w ## Linux -安装过程类似,但我没有相应的环境所以没办法测试 +安装过程类似,可以查阅网上的安装资料。也可以直接使用docker部署脚本中的gpu版本。 -# 依赖安装问题 +# 关闭管理员后台 + +由于管理员后台可以对模型进行加载和卸载操作,虽然有登录验证的保障,为了绝对安全,当对公网开放时,可以在`config.yml`中关闭管理员后台: + +```yaml +'IS_ADMIN_ENABLED': !!bool 'false' +``` + +# 常见问题 +## fasttext依赖安装问题 + +windows下可能安装不了fasttext,可以用以下命令安装,附[wheels下载地址](https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext) + +``` +# python3.10 win_amd64 +pip install https://github.com/Artrajz/archived/raw/main/fasttext/fasttext-0.9.2-cp310-cp310-win_amd64.whl +``` + +或者 + +``` +pip install fasttext -i https://pypi.artrajz.cn/simple +``` + +## pyopenjtalk依赖安装问题 由于pypi.org没有pyopenjtalk的whl文件,通常需要从源代码来安装,这一过程对于一些人来说可能比较麻烦,所以你也可以使用我构建的whl来安装。 @@ -239,6 +236,22 @@ pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/w pip install pyopenjtalk -i https://pypi.artrajz.cn/simple ``` +## Bert-VITS2版本兼容 + +修改Bert-VITS2模型的config.json,加入版本号参数`"version": "x.x.x"`,比如模型版本为1.0.1时,配置文件应该写成: + +``` +{ + "version": "1.0.1", + "train": { + "log_interval": 10, + "eval_interval": 100, + "seed": 52, + ... +``` + + + # API ## GET @@ -431,3 +444,7 @@ pip install pyopenjtalk -i https://pypi.artrajz.cn/simple - vits_chinese:https://github.com/PlayVoice/vits_chinese - Bert_VITS2:https://github.com/fishaudio/Bert-VITS2 +# 感谢所有的贡献者 + + +