From e6932aeeae538c5f3765029872aec66bad9bd8e6 Mon Sep 17 00:00:00 2001 From: Googlefan Date: Sat, 22 Feb 2025 10:42:11 +0000 Subject: [PATCH] fix: agpl issue --- .github/workflows/CI.yml | 12 ++++++------ crates/sbv2_api/Cargo.toml | 2 +- crates/sbv2_bindings/Cargo.toml | 6 +++++- crates/sbv2_core/Cargo.toml | 3 ++- crates/sbv2_core/src/jtalk.rs | 17 ++++++++++++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2ff45bc..f64f42d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -201,9 +201,9 @@ jobs: - name: Merge run: | - docker buildx imagetools create -t ${{ env.GHCR_REPO }}:cuda \ - ${{ env.GHCR_REPO }}:latest-cuda-amd64 \ - ${{ env.GHCR_REPO }}:latest-cuda-arm64 - docker buildx imagetools create -t ${{ env.GHCR_REPO }}:cpu \ - ${{ env.GHCR_REPO }}:latest-cpu-amd64 \ - ${{ env.GHCR_REPO }}:latest-cpu-arm64 + docker buildx imagetools create -t ghcr.io/${{ github.repository }}:cuda \ + ghcr.io/${{ github.repository }}:latest-cuda-amd64 \ + ghcr.io/${{ github.repository }}:latest-cuda-arm64 + docker buildx imagetools create -t ghcr.io/${{ github.repository }}:cpu \ + ghcr.io/${{ github.repository }}:latest-cpu-amd64 \ + ghcr.io/${{ github.repository }}:latest-cpu-arm64 diff --git a/crates/sbv2_api/Cargo.toml b/crates/sbv2_api/Cargo.toml index 5679be5..f482e47 100644 --- a/crates/sbv2_api/Cargo.toml +++ b/crates/sbv2_api/Cargo.toml @@ -14,7 +14,7 @@ axum = "0.8.0" dotenvy.workspace = true env_logger.workspace = true log = "0.4.22" -sbv2_core = { version = "0.2.0-alpha2", path = "../sbv2_core", features = ["aivmx"] } +sbv2_core = { version = "0.2.0-alpha6", path = "../sbv2_core", features = ["aivmx"] } serde = { version = "1.0.210", features = ["derive"] } tokio = { version = "1.40.0", features = ["full"] } utoipa = { version = "5.0.0", features = ["axum_extras"] } diff --git a/crates/sbv2_bindings/Cargo.toml b/crates/sbv2_bindings/Cargo.toml index ec2d04e..f881e1f 100644 --- a/crates/sbv2_bindings/Cargo.toml +++ b/crates/sbv2_bindings/Cargo.toml @@ -17,4 +17,8 @@ crate-type = ["cdylib"] anyhow.workspace = true ndarray.workspace = true pyo3 = { version = "0.23.0", features = ["anyhow"] } -sbv2_core = { version = "0.2.0-alpha2", path = "../sbv2_core" } +sbv2_core = { path = "../sbv2_core", features = ["std"], default-features = false } + +[features] +agpl_dict = ["sbv2_core/agpl_dict"] +default = ["agpl_dict"] \ No newline at end of file diff --git a/crates/sbv2_core/Cargo.toml b/crates/sbv2_core/Cargo.toml index bf752dc..791085b 100644 --- a/crates/sbv2_core/Cargo.toml +++ b/crates/sbv2_core/Cargo.toml @@ -31,12 +31,13 @@ zstd = "0.13.2" [features] cuda = ["ort/cuda", "std"] cuda_tf32 = ["std", "cuda"] +agpl_dict = [] std = ["dep:ort", "tokenizers/progressbar", "tokenizers/onig", "tokenizers/esaxx_fast"] dynamic = ["ort/load-dynamic", "std"] directml = ["ort/directml", "std"] tensorrt = ["ort/tensorrt", "std"] coreml = ["ort/coreml", "std"] -default = ["std"] +default = ["std", "agpl_dict"] no_std = ["tokenizers/unstable_wasm"] aivmx = ["npyz", "base64"] base64 = ["dep:base64"] diff --git a/crates/sbv2_core/src/jtalk.rs b/crates/sbv2_core/src/jtalk.rs index c837269..8359784 100644 --- a/crates/sbv2_core/src/jtalk.rs +++ b/crates/sbv2_core/src/jtalk.rs @@ -10,12 +10,23 @@ use std::sync::Arc; type JPreprocessType = JPreprocess; +#[cfg(feature = "agpl_dict")] +fn agpl_dict() -> Result> { + Ok(Some( + UserDictionary::load(include_bytes!(concat!(env!("OUT_DIR"), "/all.bin"))) + .map_err(|e| Error::LinderaError(e.to_string()))?, + )) +} + +#[cfg(not(feature = "agpl_dict"))] +fn agpl_dict() -> Result> { + Ok(None) +} + fn initialize_jtalk() -> Result { let sdic = SystemDictionaryConfig::Bundled(kind::JPreprocessDictionaryKind::NaistJdic).load()?; - 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)); + let jpreprocess = JPreprocess::with_dictionaries(sdic, agpl_dict()?); Ok(jpreprocess) }