test(transcription): GPU/CPU timing spike (opt-in) for whisper.cpp backends

This commit is contained in:
iamdoubz committed 2026-07-05 00:36:33 -05:00
1 parent 2e03eab8f8
commit 02a215c2e3
1 file changed
+33
+33
View File
@@ -296,4 +296,37 @@ mod tests {
fn audio_ctx_is_capped_at_whispers_own_maximum() {
assert_eq!(audio_ctx_for_window(60 * 16_000), 1500); // 60s window
}
/// GPU spike (opt-in): times whisper.cpp on a chosen backend against a real
/// model + wav. With `--features vulkan` and `WA_BACKEND=intel` (or nvidia/amd)
/// whisper.cpp offloads to the GPU; `WA_BACKEND=cpu` is the baseline. Run:
/// WA_WHISPER_MODEL=…ggml-base.en-q5_1.bin WA_TEST_WAV=…tts_test.wav \
/// cargo test --features vulkan gpu_transcribes -- --ignored --nocapture
#[test]
#[ignore = "requires a whisper model + wav; GPU/CPU timing spike"]
fn gpu_transcribes_and_times() {
let model = std::env::var("WA_WHISPER_MODEL").expect("set WA_WHISPER_MODEL");
let wav = std::env::var("WA_TEST_WAV").expect("set WA_TEST_WAV");
let backend = match std::env::var("WA_BACKEND").as_deref() {
Ok("cpu") => BackendId::Cpu,
Ok("nvidia") => BackendId::Nvidia,
Ok("amd") => BackendId::Amd,
_ => BackendId::Intel, // use_gpu = true for any non-CPU backend
};
let t0 = std::time::Instant::now();
let transcriber = WhisperTranscriber::load(Path::new(&model), backend).expect("load");
let load_ms = t0.elapsed().as_millis();
let t1 = std::time::Instant::now();
let segments = transcriber
.transcribe_file(Path::new(&wav))
.expect("transcribe");
let infer_ms = t1.elapsed().as_millis();
let text = segments
.iter()
.map(|s| s.text.as_str())
.collect::<Vec<_>>()
.join(" ");
eprintln!("[spike] backend={backend:?} load={load_ms}ms infer={infer_ms}ms text={text:?}");
assert!(!text.trim().is_empty(), "transcript was empty");
}
}