1 [package]
2 name = "onde-wasm"
3 version = "0.1.0"
4 edition = "2021"
5 description = "onde inference engine compiled to WASM — Whisper speech-to-text via candle-transformers"
6 license = "MIT"
7 repository = "https://github.com/ondeinference/onde"
8
9 [lib]
10 crate-type = ["cdylib"]
11
12 [dependencies]
13 # ── Core inference ────────────────────────────────────────────────────────────
14 # Pinned to the same candle rev already in the workspace lockfile (c3bb5bf).
15 # candle-transformers ships a pure-Rust Whisper implementation that compiles
16 # cleanly to wasm32-unknown-unknown — no C FFI, no platform intrinsics.
17 candle-core = { git = "https://github.com/huggingface/candle.git", rev = "c3bb5bf" }
18 candle-nn = { git = "https://github.com/huggingface/candle.git", rev = "c3bb5bf" }
19 candle-transformers = { git = "https://github.com/huggingface/candle.git", rev = "c3bb5bf" }
20
21 # ── Tokenizer ─────────────────────────────────────────────────────────────────
22 # `default-features = false` is essential — it eliminates onig_sys (C bindings
23 # to oniguruma) and esaxx-rs (C++ suffix array) which cannot compile to WASM.
24 # `unstable_wasm` is an additional feature that switches remaining regex paths
25 # to a WASM-safe fallback. Both flags together are required.
26 # Version aligned with the candle c3bb5bf workspace (tokenizers 0.22.0).
27 tokenizers = { version = "0.22", default-features = false, features = ["unstable_wasm"] }
28
29 # ── Serialisation ─────────────────────────────────────────────────────────────
30 serde = { version = "1", features = ["derive"] }
31 serde_json = "1"
32 # Aligned with candle workspace (safetensors 0.7.0).
33 safetensors = "0.7"
34
35 # ── Audio decoding ────────────────────────────────────────────────────────────
36 # hound reads 16-bit PCM WAV files — pure Rust, WASM-safe.
37 hound = "3.5"
38
39 # ── Error handling ────────────────────────────────────────────────────────────
40 anyhow = "1"
41
42 # ── Numeric utilities ─────────────────────────────────────────────────────────
43 num-traits = "0.2"
44 # Aligned with candle workspace (rand 0.9.0).
45 rand = "0.9"
46
47 # ── WASM / JS bridge ──────────────────────────────────────────────────────────
48 wasm-bindgen = "0.2"
49 wasm-bindgen-futures = "0.4"
50 js-sys = "0.3"
51 # console_error_panic_hook turns Rust panics into readable browser console errors.
52 console_error_panic_hook = { version = "0.1", optional = true }
53 # wasm-logger bridges the `log` facade to browser console.{log,warn,error}.
54 wasm-logger = "0.2"
55 log = "0.4"
56
57 # ── WASM-specific entropy source ──────────────────────────────────────────────
58 # getrandom must opt in to the JS entropy source on wasm32; otherwise rand
59 # and anything that seeds a PRNG will fail to compile.
60 [target.'cfg(target_arch = "wasm32")'.dependencies]
61 getrandom = { version = "0.2", features = ["js"] }
62
63 [features]
64 default = ["console_error_panic_hook"]
65
66 # ── wasm-pack build profile ───────────────────────────────────────────────────
67 [package.metadata.wasm-pack.profile.release]
68 wasm-opt = ["-Oz", "--enable-mutable-globals"]