From 697d330e281a047c4a1d1e89d21bcf17fa6f4825 Mon Sep 17 00:00:00 2001 From: sanami Date: Wed, 11 Sep 2024 18:42:31 +0900 Subject: [PATCH 1/2] update README.md --- .env.sample | 2 +- .gitignore | 4 +++- README.md | 50 +++++++++++++++++++++++++++++++++++--------------- test.py | 2 +- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.env.sample b/.env.sample index 2d42907..d75c186 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,6 @@ BERT_MODEL_PATH=models/deberta.onnx MODEL_PATH=models/model_tsukuyomi.onnx MODELS_PATH=models -STYLE_VECTORS_PATH=models/style_vectors.json +STYLE_VECTORS_PATH=models/style_vectors_tsukuyomi.json TOKENIZER_PATH=models/tokenizer.json ADDR=localhost:3000 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3f1a5cd..fd30d9b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ models/*.onnx models/*.json venv/ .env -output.wav \ No newline at end of file +output.wav +node_modules +models/ \ No newline at end of file diff --git a/README.md b/README.md index 374f10c..bb11fcc 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # sbv2-api -このプロジェクトはStyle-Bert-ViTS2をONNX化したものをRustで実行するのを目的としています。 + +このプロジェクトは Style-Bert-ViTS2 を ONNX 化したものを Rust で実行するのを目的としています。 学習したい場合は、Style-Bert-ViTS2 学習方法 などで調べるとよいかもしれません。 -JP-Extraしか対応していません。(基本的に対応する予定もありません) +JP-Extra しか対応していません。(基本的に対応する予定もありません) + +## ONNX 化する方法 -## ONNX化する方法 ```sh cd convert # (何かしらの方法でvenv作成(推奨)) @@ -15,38 +17,56 @@ python convert_model.py --style_file ../../style-bert-vits2/model_assets/somethi ``` ## Todo -- [x] WebAPIの実装 -- [x] Rustライブラリの実装 -- [ ] 余裕があればPyO3使ってPythonで利用可能にする -- [x] GPU対応(優先的にCUDA) -- [ ] WASM変換(ortがサポートやめたので、中止) + +- [x] WebAPI の実装 +- [x] Rust ライブラリの実装 +- [ ] 余裕があれば PyO3 使って Python で利用可能にする +- [x] GPU 対応(優先的に CUDA) +- [ ] WASM 変換(ort がサポートやめたので、中止) ## 構造説明 + - `sbv2_api` - 推論用 REST API - `sbv2_core` - 推論コア部分 -- `docker` - dockerビルドスクリプト +- `docker` - docker ビルドスクリプト + +## API の起動方法 -## APIの起動方法 ```sh cargo run -p sbv2_api -r ``` -### CUDAでの起動 +### CUDA での起動 + ```sh cargo run -p sbv2_api -r -F cuda,cuda_tf32 ``` -### Dynamic Linkサポート +### Dynamic Link サポート + ```sh ORT_DYLIB_PATH=./libonnxruntime.dll cargo run -p sbv2_api -r -F dynamic ``` -### テストコマンド +### models をインストール + +https://huggingface.co/googlefan/sbv2_onnx_models/tree/main +を models フォルダとして配置 + +### .env ファイルの作成 + ```sh -curl -XPOST -H "Content-type: application/json" -d '{"text": "こんにちは","ident": "something"}' 'http://localhost:3000/synthesize' +cp .env.sample .env +``` + +### テストコマンド + +```sh +curl -XPOST -H "Content-type: application/json" -d '{"text": "こんにちは","ident": "tsukuyomi"}' 'http://localhost:3000/synthesize' --output "output.wav" curl http://localhost:3000/models ``` ## 謝辞 + - [litagin02/Style-Bert-VITS2](https://github.com/litagin02/Style-Bert-VITS2) - このコードの書くにあたり、ベースとなる部分を参考にさせていただきました。 -- [Googlefan](https://github.com/Googlefan256) - 彼にモデルをONNXヘ変換および効率化をする方法を教わりました。 +- [Googlefan](https://github.com/Googlefan256) - 彼にモデルを ONNX ヘ変換および効率化をする方法を教わりました。 diff --git a/test.py b/test.py index 571b861..907c2a4 100644 --- a/test.py +++ b/test.py @@ -1,7 +1,7 @@ import requests res = requests.post( - "http://localhost:3001/synthesize", + "http://localhost:3000/synthesize", json={"text": "おはようございます", "ident": "tsukuyomi"}, ) with open("output.wav", "wb") as f: From f115094b8a2447d1b6c6554b0286c1afba9281cb Mon Sep 17 00:00:00 2001 From: sanami Date: Wed, 11 Sep 2024 18:51:14 +0900 Subject: [PATCH 2/2] update .gitignore --- .gitignore | 7 +++---- README.md | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fd30d9b..15193c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ target -models/*.onnx -models/*.json +models/ +!models/.gitkeep venv/ .env output.wav -node_modules -models/ \ No newline at end of file +node_modules \ No newline at end of file diff --git a/README.md b/README.md index bb11fcc..0e78ac2 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ ORT_DYLIB_PATH=./libonnxruntime.dll cargo run -p sbv2_api -r -F dynamic ### models をインストール https://huggingface.co/googlefan/sbv2_onnx_models/tree/main -を models フォルダとして配置 +の中身を models フォルダに配置 ### .env ファイルの作成