1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Moonshine ONNX transcription engine.
//!
//! This module provides transcription using the Moonshine encoder-decoder transformer model
//! via ONNX Runtime. It supports multiple model variants for different languages.
//!
//! # Model Architecture
//!
//! Moonshine uses an encoder-decoder architecture with KV caching:
//! - **Encoder**: Processes audio into hidden states (run once per transcription)
//! - **Decoder**: Autoregressively generates tokens using cached key-value states
//!
//! # Model Format
//!
//! Expects a directory containing:
//! - `encoder_model.onnx` - Audio encoder
//! - `decoder_model_merged.onnx` - Merged decoder with cache support
//! - `tokenizer.json` - BPE tokenizer vocabulary
//!
//! # Supported Variants
//!
//! | Variant | Language | Token Rate |
//! |---------|----------|------------|
//! | Tiny | English | 6 |
//! | TinyAr | Arabic | 13 |
//! | TinyZh | Chinese | 13 |
//! | TinyJa | Japanese | 13 |
//! | TinyKo | Korean | 13 |
//! | TinyUk | Ukrainian | 8 |
//! | TinyVi | Vietnamese | 13 |
//! | Base | English | 6 |
//! | BaseEs | Spanish | 6 |
//!
//! # Audio Requirements
//!
//! - Sample rate: 16 kHz
//! - Format: Mono, 16-bit PCM
//! - Duration: 0.1s to 64s
//!
//! # Example
//!
//! ```rust,no_run
//! use std::path::PathBuf;
//! use transcribe_rs::{TranscriptionEngine, engines::moonshine::{MoonshineEngine, MoonshineModelParams, ModelVariant}};
//!
//! let mut engine = MoonshineEngine::new();
//! engine.load_model_with_params(
//! &PathBuf::from("models/moonshine-tiny"),
//! MoonshineModelParams::variant(ModelVariant::Tiny),
//! )?;
//!
//! let result = engine.transcribe_file(&PathBuf::from("audio.wav"), None)?;
//! println!("Transcription: {}", result.text);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use ;