seeding
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
//! End-to-end test of the real whisper.cpp engine: a recorded speech fixture is
|
||||
//! decoded by ffmpeg and transcribed. Ignored by default because it needs a
|
||||
//! downloaded model (`scripts/fetch-model.sh`) and ffmpeg on PATH; run with:
|
||||
//! cargo test -p transcription-svc --test whisper -- --ignored
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use transcription_svc::{whisper::WhisperTranscriber, Transcriber};
|
||||
|
||||
fn manifest(rel: &str) -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(rel)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "needs a downloaded model and ffmpeg"]
|
||||
async fn transcribes_real_speech() {
|
||||
let model = std::env::var("WHISPER_MODEL")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| manifest("models/ggml-tiny.en.bin"));
|
||||
assert!(
|
||||
model.exists(),
|
||||
"model not found at {model:?} — run scripts/fetch-model.sh"
|
||||
);
|
||||
|
||||
let transcriber = WhisperTranscriber::new(model.to_str().unwrap()).expect("load model");
|
||||
let audio = std::fs::read(manifest("tests/fixtures/speech.wav")).expect("read fixture");
|
||||
|
||||
let text = transcriber
|
||||
.transcribe(&audio, "audio/wav")
|
||||
.await
|
||||
.expect("transcribe")
|
||||
.to_lowercase();
|
||||
|
||||
assert!(
|
||||
text.contains("fox"),
|
||||
"expected 'fox' in transcript, got: {text:?}"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user