Skip to content

Commit b99b5f1

Browse files
committed
build: eliminate duplicate HTTP stack by standardizing on async (tokio/reqwest)
Unified hf-hub feature declarations across all crates to use only the async API (tokio/reqwest), removing the sync API (ureq) from the dependency tree entirely. Changes: - whisperforge-core: switch hf-hub from ureq→tokio feature; add minimal tokio runtime (rt feature only) embedded in ensure_silero_model() - whisperforge: explicit default-features=false on hf-hub to prevent ureq re-entry via feature unification - vad_silero.rs: refactor ensure_silero_model() to use async API internally while preserving synchronous public signature (block_on pattern) Result: ureq@3.3.0 eliminated, single HTTP client (reqwest) in binary. Dependency reduction: 715 → 681 nodes (-34, -4.8%). No breaking API changes; tokio runtime created locally per download (negligible cost).
1 parent b024216 commit b99b5f1

4 files changed

Lines changed: 16 additions & 72 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

whisperforge-core/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ cpal = { workspace = true }
3434
ringbuf = { workspace = true }
3535
tracing = { workspace = true }
3636
ort = { workspace = true }
37-
hf-hub = { version = "0.5", default-features = false, features = ["ureq"] }
37+
hf-hub = { version = "0.5", default-features = false, features = ["tokio"] }
38+
tokio = { version = "1", default-features = false, features = ["rt"] }
3839
hound = "3.5"
3940

4041
[features]

whisperforge-core/src/vad_silero.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{Context, Result};
2-
use hf_hub::{Repo, RepoType, api::sync::ApiBuilder};
2+
use hf_hub::{Repo, RepoType, api::tokio::ApiBuilder};
33
use ort::{session::Session, value::TensorRef};
44
use std::path::{Path, PathBuf};
55

@@ -99,17 +99,26 @@ pub fn ensure_silero_model(models_dir: &Path) -> Result<PathBuf> {
9999
std::fs::create_dir_all(models_dir)
100100
.with_context(|| format!("create models dir {}", models_dir.display()))?;
101101

102+
let rt = tokio::runtime::Builder::new_current_thread()
103+
.enable_all()
104+
.build()
105+
.context("creating tokio runtime")?;
106+
rt.block_on(download_silero_model(models_dir, &target))
107+
}
108+
109+
async fn download_silero_model(_models_dir: &Path, target: &Path) -> Result<PathBuf> {
102110
let api = ApiBuilder::from_env()
103111
.build()
104112
.context("HuggingFace API init")?;
105113
let cached = api
106114
.repo(Repo::new(SILERO_REPO.to_string(), RepoType::Model))
107115
.get(SILERO_HF_FILE)
116+
.await
108117
.with_context(|| format!("download {SILERO_HF_FILE} from {SILERO_REPO}"))?;
109118

110-
std::fs::copy(&cached, &target).with_context(|| format!("copy to {}", target.display()))?;
119+
std::fs::copy(&cached, target).with_context(|| format!("copy to {}", target.display()))?;
111120

112-
Ok(target)
121+
Ok(target.to_path_buf())
113122
}
114123

115124
#[cfg(test)]

whisperforge/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ burn-wgpu = { version = "0.21.0", optional = true }
5858
burn-cuda = { version = "0.21.0", optional = true }
5959
# Model conversion (`wforge convert`) deps.
6060
safetensors = "0.7"
61-
hf-hub = { version = "0.5", features = ["tokio"] }
61+
hf-hub = { version = "0.5", default-features = false, features = ["tokio"] }
6262
tokio = { version = "1.36.0", features = ["rt-multi-thread", "rt", "signal", "macros"] }
6363
half = "2.3.1"
6464
hound = "3.5"

0 commit comments

Comments
 (0)