Files
Lumotia/crates/transcription/tests/whisper_rs_smoke.rs
Claude 89c63891fa chore: rebrand from Kon/Corbie to Magnotia
Replace all instances of the legacy product names "Kon" and "Corbie" with
"Magnotia" across user-facing copy, code identifiers, package names, bundle
ids, file paths, and documentation. Preserves the unrelated "konsole" (KDE
terminal) reference and the parent CORBEL company name.

- Renames 10 Rust crates (kon-* → magnotia-*) and the tauri binary
- Updates package.json, tauri.conf.json (productName + identifier)
- Renames CSS classes (kon-rh-* → magnotia-rh-*) and animations
- Renames brand and roadmap docs
- Regenerates Cargo.lock and package-lock.json

Verified: svelte-check passes; pure-rust crates compile under new names.
2026-04-30 13:06:55 +00:00

54 lines
1.9 KiB
Rust

//! Smoke test: whisper-rs 0.16 loads a GGUF model, transcribes silence, and
//! accepts set_initial_prompt without panicking.
//!
//! Runs only when `MAGNOTIA_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("MAGNOTIA_WHISPER_TEST_MODEL") {
Ok(p) => p,
Err(_) => {
eprintln!("MAGNOTIA_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();
}
}