diff --git a/.env.sample b/.env.sample index 2d42907..a23ae89 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,6 @@ BERT_MODEL_PATH=models/deberta.onnx -MODEL_PATH=models/model_tsukuyomi.onnx +MODEL_PATH=models/tsukuyomi.sbv2 MODELS_PATH=models -STYLE_VECTORS_PATH=models/style_vectors.json TOKENIZER_PATH=models/tokenizer.json -ADDR=localhost:3000 \ No newline at end of file +ADDR=localhost:3000 +RUST_LOG=warn \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3f1a5cd..15193c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ target -models/*.onnx -models/*.json +models/ +!models/.gitkeep venv/ .env -output.wav \ No newline at end of file +output.wav +node_modules \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3e502f1..a61dc9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,6 +228,8 @@ version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ + "jobserver", + "libc", "shlex", ] @@ -854,6 +856,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "jpreprocess" version = "0.10.0" @@ -1829,10 +1840,11 @@ dependencies = [ [[package]] name = "sbv2_core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "dotenvy", + "env_logger", "hound", "jpreprocess", "ndarray", @@ -1842,8 +1854,10 @@ dependencies = [ "regex", "serde", "serde_json", + "tar", "thiserror", "tokenizers", + "zstd", ] [[package]] @@ -2468,3 +2482,31 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zstd" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 049cedb..a9a7433 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,4 @@ members = ["sbv2_api", "sbv2_core", "sbv2_bindings"] [workspace.dependencies] anyhow = "1.0.86" dotenvy = "0.15.7" +env_logger = "0.11.5" diff --git a/README.md b/README.md index 374f10c..f196c80 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,98 @@ -# sbv2-api -このプロジェクトはStyle-Bert-ViTS2をONNX化したものをRustで実行するのを目的としています。 +# SBV2-API -学習したい場合は、Style-Bert-ViTS2 学習方法 などで調べるとよいかもしれません。 +## プログラミングに詳しくない方向け -JP-Extraしか対応していません。(基本的に対応する予定もありません) +[こちら](https://github.com/tuna2134/sbv2-gui?tab=readme-ov-file)を参照してください。 -## ONNX化する方法 -```sh -cd convert -# (何かしらの方法でvenv作成(推奨)) -pip install -r requirements.txt -python convert_deberta.py -python convert_model.py --style_file ../../style-bert-vits2/model_assets/something/style_vectors.npy --config_file ../../style-bert-vits2/model_assets/something/config.json --model_file ../../style-bert-vits2/model_assets/something/something_eXXX_sXXXX.safetensors -``` +コマンドやpythonの知識なしで簡単に使えるバージョンです。(できることはほぼ同じ) + +## このプロジェクトについて + +このプロジェクトは Style-Bert-ViTS2 を ONNX 化したものを Rust で実行するのを目的としたライブラリです。 + +JP-Extra しか対応していません。(基本的に対応する予定もありません) + +## 変換方法 + +[こちら](https://github.com/tuna2134/sbv2-api/tree/main/convert)を参照してください。 ## Todo -- [x] WebAPIの実装 -- [x] Rustライブラリの実装 -- [ ] 余裕があればPyO3使ってPythonで利用可能にする -- [x] GPU対応(優先的にCUDA) -- [ ] WASM変換(ortがサポートやめたので、中止) + +- [x] REST API の実装 +- [x] Rust ライブラリの実装 +- [x] `.sbv2`フォーマットの開発 +- [ ] PyO3 を利用し、 Python から使えるようにする +- [x] GPU 対応(CUDA) +- [x] GPU 対応(DirectML) +- [ ] WASM 変換(依存ライブラリの関係により現在は不可) ## 構造説明 + - `sbv2_api` - 推論用 REST API - `sbv2_core` - 推論コア部分 -- `docker` - dockerビルドスクリプト +- `docker` - docker ビルドスクリプト +- `convert` - onnx, sbv2フォーマットへの変換スクリプト + +## プログラミングある程度できる人向けREST API起動方法 + +### models をインストール + +https://huggingface.co/googlefan/sbv2_onnx_models/tree/main +の`tokenizer.json`,`debert.onnx`,`tsukuyomi.sbv2`を models フォルダに配置 + +### .env ファイルの作成 -## APIの起動方法 ```sh -cargo run -p sbv2_api -r +cp .env.sample .env ``` -### CUDAでの起動 +### 起動 + +CPUの場合は ```sh -cargo run -p sbv2_api -r -F cuda,cuda_tf32 +docker run -it --rm -p 3000:3000 --name sbv2 \ +-v ./models:/work/models --env-file .env \ +ghcr.io/tuna2134/sbv2-api:cpu ``` -### Dynamic Linkサポート +CUDAの場合は ```sh -ORT_DYLIB_PATH=./libonnxruntime.dll cargo run -p sbv2_api -r -F dynamic +docker run -it --rm -p 3000:3000 --name sbv2 \ +-v ./models:/work/models --env-file .env \ +--gpus all \ +ghcr.io/tuna2134/sbv2-api:cuda ``` -### テストコマンド +### 起動確認 + ```sh -curl -XPOST -H "Content-type: application/json" -d '{"text": "こんにちは","ident": "something"}' 'http://localhost:3000/synthesize' +curl -XPOST -H "Content-type: application/json" -d '{"text": "こんにちは","ident": "tsukuyomi"}' 'http://localhost:3000/synthesize' --output "output.wav" curl http://localhost:3000/models ``` +## 開発者向けガイド + +### Feature flags + +`sbv2_api`、`sbv2_core`共に +- `cuda` featureでcuda +- `cuda_tf32` featureでcudaのtf32機能 +- `tensorrt` featureでbert部分のtensorrt利用 +- `dynamic` featureで手元のonnxruntime共有ライブラリを利用(`ORT_DYLIB_PATH=./libonnxruntime.dll`などで指定) +- `directml` featureでdirectmlの利用 +ができます。 + +### 環境変数 + +以下の環境変数はライブラリ側では適用されません。 + +ライブラリAPIについては`https://docs.rs/sbv2_core`を参照してください。 + +- `ADDR` `localhost:3000`などのようにサーバー起動アドレスをコントロールできます。 +- `MODELS_PATH` sbv2モデルの存在するフォルダを指定できます。 +- `RUST_LOG` おなじみlog levelです。 + ## 謝辞 + - [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/convert/README.md b/convert/README.md new file mode 100644 index 0000000..3dbf86d --- /dev/null +++ b/convert/README.md @@ -0,0 +1,36 @@ +# 変換方法 + +## 初心者向け準備 + +わかる人は飛ばしてください。 + +1. pythonを入れます。3.11.8で動作確認をしていますが、最近のバージョンなら大体動くはずです。 + +4. `cd convert` + +3. `python -m venv venv` + +4. `source venv/bin/activate` + +5. `pip install -r requirements.txt` + +## モデル変換 + +1. 変換したいモデルの`.safetensors`で終わるファイルの位置を特定してください。 + +2. 同様に`config.json`、`style_vectors.npy`というファイルを探してください。 + +3. 以下のコマンドを実行します。 +```sh +python convert_model.py --style_file "ここにstyle_vectors.npyの場所" --config_file "同様にconfig.json場所" --model_file "同様に.safetensorsで終わるファイルの場所" +``` + +4. `models/名前.sbv2`というファイルが出力されます。GUI版のモデルファイルに入れてあげたら使えます。 + +## Deberta変換 + +意味が分からないならおそらく変換しなくてもいいってことです。 + +venvを用意し、requirementsを入れて、`python convert_model.py`を実行するだけです。 + +`models/deberta.onnx`と`models/tokenizer.json`が出力されたら成功です。 \ No newline at end of file diff --git a/convert/convert_model.py b/convert/convert_model.py index a8097db..17ddc6c 100644 --- a/convert/convert_model.py +++ b/convert/convert_model.py @@ -1,5 +1,6 @@ import numpy as np import json +from io import BytesIO from style_bert_vits2.nlp import bert_models from style_bert_vits2.constants import Languages from style_bert_vits2.models.infer import get_net_g, get_text @@ -11,6 +12,9 @@ from style_bert_vits2.constants import ( DEFAULT_STYLE_WEIGHT, Languages, ) +import os +from tarfile import open as taropen, TarInfo +from zstandard import ZstdCompressor from style_bert_vits2.tts_model import TTSModel import numpy as np from argparse import ArgumentParser @@ -141,3 +145,23 @@ torch.onnx.export( ], output_names=["output"], ) +os.system(f"onnxsim ../models/model_{out_name}.onnx ../models/model_{out_name}.onnx") +onnxfile = open(f"../models/model_{out_name}.onnx", "rb").read() +stylefile = open(f"../models/style_vectors_{out_name}.json", "rb").read() +version = bytes("1", "utf8") +with taropen(f"../models/tmp_{out_name}.sbv2tar", "w") as w: + + def add_tar(f, b): + t = TarInfo(f) + t.size = len(b) + w.addfile(t, BytesIO(b)) + + add_tar("version.txt", version) + add_tar("model.onnx", onnxfile) + add_tar("style_vectors.json", stylefile) +open(f"../models/{out_name}.sbv2", "wb").write( + ZstdCompressor(threads=-1, level=22).compress( + open(f"../models/tmp_{out_name}.sbv2tar", "rb").read() + ) +) +os.unlink(f"../models/tmp_{out_name}.sbv2tar") diff --git a/convert/requirements.txt b/convert/requirements.txt index 00790b8..5f17210 100644 --- a/convert/requirements.txt +++ b/convert/requirements.txt @@ -1,3 +1,4 @@ style-bert-vits2 onnxsim -numpy<3 \ No newline at end of file +numpy<2 +zstandard \ No newline at end of file diff --git a/docker/cuda.Dockerfile b/docker/cuda.Dockerfile index dd5215e..1b1b637 100644 --- a/docker/cuda.Dockerfile +++ b/docker/cuda.Dockerfile @@ -2,9 +2,9 @@ FROM rust AS builder WORKDIR /work COPY . . RUN cargo build -r --bin sbv2_api -F cuda,cuda_tf32 - -FROM nvidia/cuda:12.6.1-cudnn-runtime-ubuntu24.04 +FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 WORKDIR /work COPY --from=builder /work/target/release/sbv2_api /work/main COPY --from=builder /work/target/release/*.so /work +ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/work CMD ["/work/main"] \ No newline at end of file diff --git a/docker/run.sh b/docker/run.sh deleted file mode 100644 index 7b32775..0000000 --- a/docker/run.sh +++ /dev/null @@ -1 +0,0 @@ -docker run -it --rm -p 3000:3000 --name sbv2 -v ./models:/work/models --env-file .env sbv2 \ No newline at end of file diff --git a/docker/run_cpu.sh b/docker/run_cpu.sh new file mode 100755 index 0000000..3e6b141 --- /dev/null +++ b/docker/run_cpu.sh @@ -0,0 +1,3 @@ +docker run -it --rm -p 3000:3000 --name sbv2 \ +-v ./models:/work/models --env-file .env \ +ghcr.io/tuna2134/sbv2-api:cpu \ No newline at end of file diff --git a/docker/run_cuda.sh b/docker/run_cuda.sh new file mode 100755 index 0000000..38e6afa --- /dev/null +++ b/docker/run_cuda.sh @@ -0,0 +1,4 @@ +docker run -it --rm -p 3000:3000 --name sbv2 \ +-v ./models:/work/models --env-file .env \ +--gpus all \ +ghcr.io/tuna2134/sbv2-api:cuda \ No newline at end of file diff --git a/sbv2_api/Cargo.toml b/sbv2_api/Cargo.toml index b1ac73a..4b0b43a 100644 --- a/sbv2_api/Cargo.toml +++ b/sbv2_api/Cargo.toml @@ -7,13 +7,16 @@ edition = "2021" anyhow.workspace = true axum = "0.7.5" dotenvy.workspace = true -env_logger = "0.11.5" +env_logger.workspace = true log = "0.4.22" -sbv2_core = { version = "0.1.0", path = "../sbv2_core" } +sbv2_core = { version = "0.1.1", path = "../sbv2_core" } serde = { version = "1.0.210", features = ["derive"] } tokio = { version = "1.40.0", features = ["full"] } [features] +coreml = ["sbv2_core/coreml"] cuda = ["sbv2_core/cuda"] cuda_tf32 = ["sbv2_core/cuda_tf32"] dynamic = ["sbv2_core/dynamic"] +directml = ["sbv2_core/directml"] +tensorrt = ["sbv2_core/tensorrt"] \ No newline at end of file diff --git a/sbv2_api/src/main.rs b/sbv2_api/src/main.rs index e956e93..a10ec0a 100644 --- a/sbv2_api/src/main.rs +++ b/sbv2_api/src/main.rs @@ -26,6 +26,7 @@ fn sdp_default() -> f32 { fn length_default() -> f32 { 1.0 } + #[derive(Deserialize)] struct SynthesizeRequest { text: String, @@ -88,6 +89,20 @@ impl AppState { .iter() .collect::(), ); + } else if name.ends_with(".sbv2") { + let entry = &name[..name.len() - 5]; + log::info!("Try loading: {entry}"); + let sbv2_bytes = match fs::read(format!("{models}/{entry}.sbv2")).await { + Ok(b) => b, + Err(e) => { + log::warn!("Error loading sbv2_bytes from file {entry}: {e}"); + continue; + } + }; + if let Err(e) = tts_model.load_sbv2file(entry, sbv2_bytes) { + log::warn!("Error loading {entry}: {e}"); + }; + log::info!("Loaded: {entry}"); } } for entry in entries { @@ -110,6 +125,7 @@ impl AppState { if let Err(e) = tts_model.load(&entry, style_vectors_bytes, vits2_bytes) { log::warn!("Error loading {entry}: {e}"); }; + log::info!("Loaded: {entry}"); } Ok(Self { tts_model: Arc::new(Mutex::new(tts_model)), @@ -119,7 +135,7 @@ impl AppState { #[tokio::main] async fn main() -> anyhow::Result<()> { - dotenvy::dotenv().ok(); + dotenvy::dotenv_override().ok(); env_logger::init(); let app = Router::new() .route("/", get(|| async { "Hello, World!" })) diff --git a/sbv2_core/Cargo.toml b/sbv2_core/Cargo.toml index 37203d9..63badb6 100644 --- a/sbv2_core/Cargo.toml +++ b/sbv2_core/Cargo.toml @@ -1,11 +1,16 @@ [package] name = "sbv2_core" -version = "0.1.0" +description = "Style-Bert-VITSの推論ライブラリ" +version = "0.1.1" edition = "2021" +license = "MIT" +readme = "../README.md" +repository = "https://github.com/tuna2134/sbv2-api" [dependencies] anyhow.workspace = true dotenvy.workspace = true +env_logger.workspace = true hound = "3.5.1" jpreprocess = { version = "0.10.0", features = ["naist-jdic"] } ndarray = "0.16.1" @@ -15,10 +20,15 @@ ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.6" } regex = "1.10.6" serde = { version = "1.0.210", features = ["derive"] } serde_json = "1.0.128" +tar = "0.4.41" thiserror = "1.0.63" tokenizers = "0.20.0" +zstd = "0.13.2" [features] cuda = ["ort/cuda"] cuda_tf32 = [] -dynamic = ["ort/load-dynamic"] \ No newline at end of file +dynamic = ["ort/load-dynamic"] +directml = ["ort/directml"] +tensorrt = ["ort/tensorrt"] +coreml = ["ort/coreml"] \ No newline at end of file diff --git a/sbv2_core/src/main.rs b/sbv2_core/src/main.rs index 5d27c65..925e735 100644 --- a/sbv2_core/src/main.rs +++ b/sbv2_core/src/main.rs @@ -4,18 +4,15 @@ use sbv2_core::tts; use std::env; fn main() -> anyhow::Result<()> { - dotenvy::dotenv().ok(); + dotenvy::dotenv_override().ok(); + env_logger::init(); let text = "眠たい"; let ident = "aaa"; let mut tts_holder = tts::TTSModelHolder::new( &fs::read(env::var("BERT_MODEL_PATH")?)?, &fs::read(env::var("TOKENIZER_PATH")?)?, )?; - tts_holder.load( - ident, - fs::read(env::var("STYLE_VECTORS_PATH")?)?, - fs::read(env::var("MODEL_PATH")?)?, - )?; + tts_holder.load_sbv2file(ident, fs::read(env::var("MODEL_PATH")?)?)?; let (bert_ori, phones, tones, lang_ids) = tts_holder.parse_text(text)?; @@ -32,6 +29,14 @@ fn main() -> anyhow::Result<()> { )?; std::fs::write("output.wav", data)?; let now = Instant::now(); + for _ in 0..10 { + tts_holder.parse_text(text)?; + } + println!( + "Time taken(parse_text): {}ms/it", + now.elapsed().as_millis() / 10 + ); + let now = Instant::now(); for _ in 0..10 { tts_holder.synthesize( ident, @@ -44,6 +49,9 @@ fn main() -> anyhow::Result<()> { 1.0, )?; } - println!("Time taken: {}", now.elapsed().as_millis()); + println!( + "Time taken(synthesize): {}ms/it", + now.elapsed().as_millis() / 10 + ); Ok(()) } diff --git a/sbv2_core/src/model.rs b/sbv2_core/src/model.rs index 1598e9b..2b975ca 100644 --- a/sbv2_core/src/model.rs +++ b/sbv2_core/src/model.rs @@ -4,11 +4,25 @@ use ndarray::{array, s, Array1, Array2, Axis}; use ort::{GraphOptimizationLevel, Session}; use std::io::Cursor; -#[allow(clippy::vec_init_then_push)] -pub fn load_model>(model_file: P) -> Result { +#[allow(clippy::vec_init_then_push, unused_variables)] +pub fn load_model>(model_file: P, bert: bool) -> Result { let mut exp = Vec::new(); + #[cfg(feature = "tensorrt")] + { + if bert { + exp.push( + ort::TensorRTExecutionProvider::default() + .with_fp16(true) + .with_profile_min_shapes("input_ids:1x1,attention_mask:1x1") + .with_profile_max_shapes("input_ids:1x100,attention_mask:1x100") + .with_profile_opt_shapes("input_ids:1x25,attention_mask:1x25") + .build(), + ); + } + } #[cfg(feature = "cuda")] { + #[allow(unused_mut)] let mut cuda = ort::CUDAExecutionProvider::default() .with_conv_algorithm_search(ort::CUDAExecutionProviderCuDNNConvAlgoSearch::Default); #[cfg(feature = "cuda_tf32")] @@ -17,6 +31,14 @@ pub fn load_model>(model_file: P) -> Result { } exp.push(cuda.build()); } + #[cfg(feature = "directml")] + { + exp.push(ort::DirectMLExecutionProvider::default().build()); + } + #[cfg(feature = "coreml")] + { + exp.push(ort::CoreMLExecutionProvider::default().build()); + } exp.push(ort::CPUExecutionProvider::default().build()); Ok(Session::builder()? .with_execution_providers(exp)? @@ -26,6 +48,7 @@ pub fn load_model>(model_file: P) -> Result { .with_inter_threads(num_cpus::get_physical())? .commit_from_memory(model_file.as_ref())?) } + #[allow(clippy::too_many_arguments)] pub fn synthesize( session: &Session, diff --git a/sbv2_core/src/tts.rs b/sbv2_core/src/tts.rs index 5a8c454..0d50096 100644 --- a/sbv2_core/src/tts.rs +++ b/sbv2_core/src/tts.rs @@ -2,7 +2,10 @@ use crate::error::{Error, Result}; use crate::{bert, jtalk, model, nlp, norm, style, tokenizer, utils}; use ndarray::{concatenate, s, Array, Array1, Array2, Axis}; use ort::Session; +use std::io::{Cursor, Read}; +use tar::Archive; use tokenizers::Tokenizer; +use zstd::decode_all; #[derive(PartialEq, Eq, Clone)] pub struct TTSIdent(String); @@ -38,7 +41,7 @@ pub struct TTSModelHolder { impl TTSModelHolder { pub fn new>(bert_model_bytes: P, tokenizer_bytes: P) -> Result { - let bert = model::load_model(bert_model_bytes)?; + let bert = model::load_model(bert_model_bytes, true)?; let jtalk = jtalk::JTalk::new()?; let tokenizer = tokenizer::get_tokenizer(tokenizer_bytes)?; Ok(TTSModelHolder { @@ -53,6 +56,35 @@ impl TTSModelHolder { self.models.iter().map(|m| m.ident.to_string()).collect() } + pub fn load_sbv2file, P: AsRef<[u8]>>( + &mut self, + ident: I, + sbv2_bytes: P, + ) -> Result<()> { + let mut arc = Archive::new(Cursor::new(decode_all(Cursor::new(sbv2_bytes.as_ref()))?)); + let mut vits2 = None; + let mut style_vectors = None; + let mut et = arc.entries()?; + while let Some(Ok(mut e)) = et.next() { + let pth = String::from_utf8_lossy(&e.path_bytes()).to_string(); + let mut b = Vec::with_capacity(e.size() as usize); + e.read_to_end(&mut b)?; + match pth.as_str() { + "model.onnx" => vits2 = Some(b), + "style_vectors.json" => style_vectors = Some(b), + _ => continue, + } + } + if style_vectors.is_none() { + return Err(Error::ModelNotFoundError("style_vectors".to_string())); + } + if vits2.is_none() { + return Err(Error::ModelNotFoundError("vits2".to_string())); + } + self.load(ident, style_vectors.unwrap(), vits2.unwrap())?; + Ok(()) + } + pub fn load, P: AsRef<[u8]>>( &mut self, ident: I, @@ -62,7 +94,7 @@ impl TTSModelHolder { let ident = ident.into(); if self.find_model(ident.clone()).is_err() { self.models.push(TTSModel { - vits2: model::load_model(vits2_bytes)?, + vits2: model::load_model(vits2_bytes, false)?, style_vectors: style::load_style(style_vectors_bytes)?, ident, }) diff --git a/sbv2_core/src/utils.rs b/sbv2_core/src/utils.rs index 9cf54f9..0d38a49 100644 --- a/sbv2_core/src/utils.rs +++ b/sbv2_core/src/utils.rs @@ -2,11 +2,6 @@ pub fn intersperse(slice: &[T], sep: T) -> Vec where T: Clone, { - /* - result = [item] * (len(lst) * 2 + 1) - result[1::2] = lst - return result - */ let mut result = vec![sep.clone(); slice.len() * 2 + 1]; result .iter_mut() @@ -15,24 +10,3 @@ where .for_each(|(r, s)| *r = s.clone()); result } - -/* -fn tile(arr: &Array2, reps: (usize, usize)) -> Array2 { - let (rows, cols) = arr.dim(); - let (rep_rows, rep_cols) = reps; - - let mut result = Array::zeros((rows * rep_rows, cols * rep_cols)); - - for i in 0..rep_rows { - for j in 0..rep_cols { - let view = result.slice_mut(s![ - i * rows..(i + 1) * rows, - j * cols..(j + 1) * cols - ]); - view.assign(arr); - } - } - - result -} -*/ 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: