mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
feat: wasm would work
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,10 +1,10 @@
|
|||||||
target
|
target/
|
||||||
models/
|
models/
|
||||||
!models/.gitkeep
|
!models/.gitkeep
|
||||||
venv/
|
venv/
|
||||||
.env
|
.env
|
||||||
output.wav
|
*.wav
|
||||||
node_modules
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
*.csv
|
*.csv
|
||||||
*.bin
|
*.bin
|
||||||
@@ -6,6 +6,7 @@ description.workspace = true
|
|||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
documentation.workspace = true
|
documentation.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ description.workspace = true
|
|||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
documentation.workspace = true
|
documentation.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[lib]
|
[lib]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ description.workspace = true
|
|||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
documentation.workspace = true
|
documentation.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ description.workspace = true
|
|||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
documentation.workspace = true
|
documentation.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
wasm-pack build --target web sbv2_wasm
|
#!/bin/sh
|
||||||
wasm-opt -O3 -o ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
wasm-pack build --target web ./crates/sbv2_wasm --release
|
||||||
wasm-strip ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
wasm-opt -O3 -o ./crates/sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./crates/sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
||||||
mkdir -p ./sbv2_wasm/dist
|
wasm-strip ./crates/sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
||||||
cp ./sbv2_wasm/sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./sbv2_wasm/dist/sbv2_wasm_bg.wasm
|
mkdir -p ./crates/sbv2_wasm/dist
|
||||||
|
cp ./crates/sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./crates/sbv2_wasm/dist/sbv2_wasm_bg.wasm
|
||||||
|
cd ./crates/sbv2_wasm
|
||||||
|
pnpm build
|
||||||
@@ -3,9 +3,12 @@ import fs from "node:fs/promises";
|
|||||||
|
|
||||||
ModelHolder.globalInit(await fs.readFile("./dist/sbv2_wasm_bg.wasm"));
|
ModelHolder.globalInit(await fs.readFile("./dist/sbv2_wasm_bg.wasm"));
|
||||||
const holder = await ModelHolder.create(
|
const holder = await ModelHolder.create(
|
||||||
(await fs.readFile("../models/tokenizer.json")).toString("utf-8"),
|
(await fs.readFile("../../models/tokenizer.json")).toString("utf-8"),
|
||||||
await fs.readFile("../models/deberta.onnx"),
|
await fs.readFile("../../models/deberta.onnx"),
|
||||||
|
);
|
||||||
|
await holder.load(
|
||||||
|
"tsukuyomi",
|
||||||
|
await fs.readFile("../../models/tsukuyomi.sbv2"),
|
||||||
);
|
);
|
||||||
await holder.load("tsukuyomi", await fs.readFile("../models/iroha2.sbv2"));
|
|
||||||
await fs.writeFile("out.wav", await holder.synthesize("tsukuyomi", "おはよう"));
|
await fs.writeFile("out.wav", await holder.synthesize("tsukuyomi", "おはよう"));
|
||||||
holder.unload("tsukuyomi");
|
holder.unload("tsukuyomi");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sbv2",
|
"name": "sbv2",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0-alpha6",
|
||||||
"description": "Style Bert VITS2 wasm",
|
"description": "Style Bert VITS2 wasm",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -21,9 +21,5 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"onnxruntime-web": "^1.20.1"
|
"onnxruntime-web": "^1.20.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["dist/*", "package.json", "README.md", "pkg/*.ts", "pkg/*.js"]
|
||||||
"dist/*",
|
|
||||||
"package.json",
|
|
||||||
"README.md"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ export class ModelHolder {
|
|||||||
style_vec: e,
|
style_vec: e,
|
||||||
sdp_ratio: new Tensor("float32", [f]),
|
sdp_ratio: new Tensor("float32", [f]),
|
||||||
length_scale: new Tensor("float32", [g]),
|
length_scale: new Tensor("float32", [g]),
|
||||||
|
noise_scale: new Tensor("float32", [0.677]),
|
||||||
|
noise_scale_w: new Tensor("float32", [0.8]),
|
||||||
})
|
})
|
||||||
).output;
|
).output;
|
||||||
return [new Uint32Array(res.dims), await res.getData(true)];
|
return [new Uint32Array(res.dims), await res.getData(true)];
|
||||||
|
|||||||
Reference in New Issue
Block a user