Skip to main content

basic/
basic.rs

1//! Minimal transcription example.
2//!
3//! Run with:
4//! ```bash
5//! cargo run --example basic
6//! ```
7//!
8//! On the first run, the default model (~500 MB) will be downloaded
9//! automatically into your platform cache directory.
10
11use memo_stt::SttEngine;
12
13fn main() -> Result<(), Box<dyn std::error::Error>> {
14    println!("Creating STT engine (this may download the model on first run)...");
15    let mut engine = SttEngine::new_default(16000)?;
16
17    println!("Warming up...");
18    engine.warmup()?;
19
20    println!("Engine ready.");
21    println!();
22    println!("To transcribe, pass 16-bit mono PCM samples:");
23    println!("    let samples: Vec<i16> = /* your audio */;");
24    println!("    let text = engine.transcribe(&samples)?;");
25
26    // Example with one second of silence (just to demonstrate the call shape).
27    let samples = vec![0i16; 16_000];
28    match engine.transcribe(&samples) {
29        Ok(text) => println!("Transcribed (silence): {:?}", text),
30        Err(e) => println!("Transcribe error: {}", e),
31    }
32
33    Ok(())
34}