This commit is contained in:
Googlefan
2025-02-22 08:56:10 +00:00
parent 5b364a3c10
commit b9aa8d1b7c
9 changed files with 82 additions and 21 deletions

21
Cargo.lock generated
View File

@@ -697,6 +697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
@@ -705,6 +706,12 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-io"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
[[package]]
name = "futures-sink"
version = "0.3.31"
@@ -724,9 +731,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
dependencies = [
"futures-core",
"futures-io",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
@@ -2101,6 +2112,7 @@ dependencies = [
"base64 0.22.1",
"bytes",
"encoding_rs",
"futures-channel",
"futures-core",
"futures-util",
"h2",
@@ -2222,7 +2234,7 @@ checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
[[package]]
name = "sbv2_api"
version = "0.2.0-alpha4"
version = "0.2.0-alpha6"
dependencies = [
"anyhow",
"axum",
@@ -2238,7 +2250,7 @@ dependencies = [
[[package]]
name = "sbv2_bindings"
version = "0.2.0-alpha4"
version = "0.2.0-alpha6"
dependencies = [
"anyhow",
"ndarray",
@@ -2248,7 +2260,7 @@ dependencies = [
[[package]]
name = "sbv2_core"
version = "0.2.0-alpha4"
version = "0.2.0-alpha6"
dependencies = [
"anyhow",
"base64 0.22.1",
@@ -2262,6 +2274,7 @@ dependencies = [
"once_cell",
"ort",
"regex",
"reqwest",
"serde",
"serde_json",
"tar",
@@ -2272,7 +2285,7 @@ dependencies = [
[[package]]
name = "sbv2_wasm"
version = "0.1.0"
version = "0.2.0-alpha6"
dependencies = [
"js-sys",
"ndarray",

View File

@@ -2,6 +2,15 @@
resolver = "2"
members = ["./crates/sbv2_api", "./crates/sbv2_core", "./crates/sbv2_bindings", "./crates/sbv2_wasm"]
[workspace.package]
version = "0.2.0-alpha6"
edition = "2021"
description = "Style-Bert-VITSの推論ライブラリ"
license = "MIT"
readme = "./README.md"
repository = "https://github.com/tuna2134/sbv2-api"
documentation = "https://docs.rs/sbv2_core"
[workspace.dependencies]
anyhow = "1.0.96"
dotenvy = "0.15.7"

View File

@@ -1,7 +1,11 @@
[package]
name = "sbv2_api"
version = "0.2.0-alpha4"
edition = "2021"
version.workspace = true
edition.workspace = true
description.workspace = true
readme.workspace = true
repository.workspace = true
documentation.workspace = true
[dependencies]
anyhow.workspace = true

View File

@@ -1,7 +1,11 @@
[package]
name = "sbv2_bindings"
version = "0.2.0-alpha4"
edition = "2021"
version.workspace = true
edition.workspace = true
description.workspace = true
readme.workspace = true
repository.workspace = true
documentation.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]

View File

@@ -1,12 +1,11 @@
[package]
name = "sbv2_core"
description = "Style-Bert-VITSの推論ライブラリ"
version = "0.2.0-alpha4"
edition = "2021"
license = "MIT"
readme = "../README.md"
repository = "https://github.com/tuna2134/sbv2-api"
documentation = "https://docs.rs/sbv2_core"
version.workspace = true
edition.workspace = true
description.workspace = true
readme.workspace = true
repository.workspace = true
documentation.workspace = true
[dependencies]
anyhow.workspace = true
@@ -40,3 +39,6 @@ default = ["std"]
no_std = ["tokenizers/unstable_wasm"]
aivmx = ["npyz", "base64"]
base64 = ["dep:base64"]
[build-dependencies]
reqwest = { version = "0.12.12", features = ["blocking"] }

19
crates/sbv2_core/build.rs Normal file
View File

@@ -0,0 +1,19 @@
use std::env;
use std::fs;
use std::io::copy;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = env::var("OUT_DIR")?;
let out_path = Path::new(&out_dir).join("all.bin");
if !out_path.exists() {
println!("cargo:warning=Downloading dictionary file...");
let mut response = reqwest::blocking::get(
"https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin",
)?;
let mut file = fs::File::create(&out_path)?;
copy(&mut response, &mut file)?;
}
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}

View File

@@ -13,7 +13,7 @@ type JPreprocessType = JPreprocess<DefaultTokenizer>;
fn initialize_jtalk() -> Result<JPreprocessType> {
let sdic =
SystemDictionaryConfig::Bundled(kind::JPreprocessDictionaryKind::NaistJdic).load()?;
let u = UserDictionary::load(include_bytes!("./dic/all.dic/all.bin"))
let u = UserDictionary::load(include_bytes!(concat!(env!("OUT_DIR"), "/all.bin")))
.map_err(|e| Error::LinderaError(e.to_string()))?;
let jpreprocess = JPreprocess::with_dictionaries(sdic, Some(u));
Ok(jpreprocess)

View File

@@ -15,13 +15,19 @@ fn main_inner() -> anyhow::Result<()> {
.ok()
.and_then(|x| x.parse().ok()),
)?;
let mp = env::var("MODEL_PATH")?;
let b = fs::read(&mp)?;
#[cfg(not(feature = "aivmx"))]
{
tts_holder.load_sbv2file(ident, fs::read(env::var("MODEL_PATH")?)?)?;
tts_holder.load_sbv2file(ident, b)?;
}
#[cfg(feature = "aivmx")]
{
tts_holder.load_aivmx(ident, fs::read(env::var("MODEL_PATH")?)?)?;
if mp.ends_with(".sbv2") {
tts_holder.load_sbv2file(ident, b)?;
} else {
tts_holder.load_aivmx(ident, b)?;
}
}
let audio =

View File

@@ -1,7 +1,11 @@
[package]
name = "sbv2_wasm"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
description.workspace = true
readme.workspace = true
repository.workspace = true
documentation.workspace = true
[lib]
crate-type = ["cdylib", "rlib"]