Skip to content

Commit ce3501e

Browse files
chore(moonshine): Address remaining PR #259 review nitpicks
This commit addresses the remaining low-priority review comments from PR #259. Test Improvements: - Adds `serial_test` to isolate environment variable tests in `moonshine_e2e.rs`. - Adds a test for `verify_sample_rate()` in `moonshine.rs`. - Adds a test for buffer overflow protection in `moonshine.rs`. - Refactors `load_test_audio()` to validate sample rate and channels and removes duplicated test code. Code Cleanup: - Removes the unused `active_config` field from `MoonshinePlugin`. Script Improvements: - Uses `set -euo pipefail` in `install-moonshine-deps.sh` and `verify-stt-setup.sh`.
1 parent ccd2ca5 commit ce3501e

File tree

17 files changed

+1225
-31
lines changed

17 files changed

+1225
-31
lines changed

.lintstagedrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"*": [
1212
"mise run typos"
1313
]
14-
}
14+
}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project are documented here.
55
## [Unreleased]
66

77
### Added
8+
- **Moonshine STT Plugin** - CPU-optimized speech recognition using UsefulSensors' Moonshine model via PyO3/HuggingFace Transformers
9+
- 5x faster than Whisper on CPU with comparable accuracy (~2.5% WER)
10+
- English-only, optimized for 16kHz audio
11+
- Two model variants: Base (61M params, ~500MB) and Tiny (27M params, ~300MB)
12+
- Auto-downloads models from HuggingFace Hub on first use
13+
- Environment variables: `MOONSHINE_MODEL` (base/tiny), `MOONSHINE_MODEL_PATH`
14+
- Requires Python 3.8+ with transformers, torch, librosa
15+
- Install deps: `./scripts/install-moonshine-deps.sh`
16+
- Build: `cargo build --features moonshine`
17+
818
- **NVIDIA Parakeet STT Plugin** - GPU-accelerated speech recognition using NVIDIA's Parakeet model via pure-Rust parakeet-rs library (#XXX)
919
- Supports largest available model: nvidia/parakeet-tdt-1.1b (1.1 billion parameters)
1020
- TDT variant: Multilingual support for 25 languages with automatic detection

Cargo.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/app/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ similar-asserts = "1.5"
6868
default = ["silero", "text-injection"]
6969
live-hardware-tests = []
7070
parakeet = ["coldvox-stt/parakeet"]
71+
moonshine = ["coldvox-stt/moonshine"]
7172
whisper = [] # Temporarily stubbed; new pure-Rust backend will populate this
7273
no-stt = []
7374
examples = []

crates/app/src/stt/plugin_manager.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,13 @@ impl SttPluginManager {
579579
use coldvox_stt::plugins::parakeet::ParakeetPluginFactory;
580580
registry.register(Box::new(ParakeetPluginFactory::new()));
581581
}
582+
583+
// Register Moonshine plugin if the moonshine feature is enabled
584+
#[cfg(feature = "moonshine")]
585+
{
586+
use coldvox_stt::plugins::moonshine::MoonshinePluginFactory;
587+
registry.register(Box::new(MoonshinePluginFactory::new()));
588+
}
582589
}
583590

584591
/// Initialize the plugin manager and select the best available plugin

crates/coldvox-stt/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ coldvox-telemetry = { path = "../coldvox-telemetry" }
1919
# Parakeet STT via pure Rust ONNX Runtime
2020
parakeet-rs = { version = "0.2", optional = true }
2121

22+
# Moonshine STT via PyO3/HuggingFace
23+
pyo3 = { version = "0.22", optional = true, features = ["auto-initialize"] }
24+
tempfile = { version = "3.8", optional = true }
25+
hound = { version = "3.5", optional = true }
26+
27+
[dev-dependencies]
28+
anyhow = "1.0"
29+
serial_test = "3.0.0"
30+
2231
[features]
2332
default = []
2433
parakeet = ["dep:parakeet-rs"]
2534
whisper = [] # Placeholder until new backend is implemented
35+
moonshine = ["dep:pyo3", "dep:tempfile", "dep:hound"]
2636
coqui = []
2737
leopard = []
2838
silero-stt = []

crates/coldvox-stt/src/plugins/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ pub mod noop;
88
#[cfg(feature = "parakeet")]
99
pub mod parakeet;
1010

11+
#[cfg(feature = "moonshine")]
12+
pub mod moonshine;
13+
1114
#[cfg(feature = "whisper")]
1215
pub mod whisper_cpp;
1316

@@ -27,3 +30,6 @@ pub use noop::NoOpPlugin;
2730

2831
#[cfg(feature = "parakeet")]
2932
pub use parakeet::ParakeetPluginFactory;
33+
34+
#[cfg(feature = "moonshine")]
35+
pub use moonshine::{MoonshineModelSize, MoonshinePlugin, MoonshinePluginFactory};

0 commit comments

Comments
 (0)