//! Smoke test: whisper-rs 0.16 loads a GGUF model, transcribes silence, and //! accepts set_initial_prompt without panicking. //! //! Runs only when `KON_WHISPER_TEST_MODEL` is set to the path of a //! ggml/gguf whisper model on disk. Otherwise the test exits quiet. use std::env; #[test] fn whisper_rs_smoke_loads_and_transcribes() { let model_path = match env::var("KON_WHISPER_TEST_MODEL") { Ok(p) => p, Err(_) => { eprintln!("KON_WHISPER_TEST_MODEL not set — skipping"); return; } }; use whisper_rs::{FullParams, SamplingStrategy, WhisperContext, WhisperContextParameters}; let ctx = WhisperContext::new_with_params(&model_path, WhisperContextParameters::default()) .expect("whisper model load"); let mut state = ctx.create_state().expect("whisper state"); let mut params = FullParams::new(SamplingStrategy::Greedy { best_of: 1 }); params.set_language(Some("en")); params.set_initial_prompt("Wren, CORBEL, ADHD"); params.set_n_threads(2); params.set_print_special(false); params.set_print_progress(false); params.set_print_realtime(false); // 1 second of silence at 16 kHz. let samples = vec![0.0_f32; 16_000]; state.full(params, &samples).expect("transcribe"); // full_n_segments is infallible in whisper-rs 0.16 — returns c_int. let n = state.full_n_segments(); // Silence may produce zero segments; the test only confirms the pipeline runs. assert!(n >= 0, "segment count must be non-negative"); // Exercise the segment accessor API we will use in WhisperRsBackend. for i in 0..n { let seg = state .get_segment(i) .expect("get_segment returns Some for in-range index"); let _text: &str = seg.to_str().unwrap_or(""); let _t0: i64 = seg.start_timestamp(); let _t1: i64 = seg.end_timestamp(); } }