diff --git a/crates/mcp/src/tools/listen.rs b/crates/mcp/src/tools/listen.rs index 8166de6..a65ee91 100644 --- a/crates/mcp/src/tools/listen.rs +++ b/crates/mcp/src/tools/listen.rs @@ -283,8 +283,8 @@ fn speech_model(srv: &mut Server, args: &Value) -> Reply { return Reply::err("a speech model download is already running: speech_model shows its progress"); } let model = opt_str(args, "model").unwrap_or("base"); - if let Err(e) = check_model(model) { - return Reply::err(e); + if !MODELS.contains(&model) { + return Reply::err(format!("model `{model}` is not one of {}", MODELS.join(", "))); } if engine::speech::installed_models().contains(&model) { return Reply::ok(format!("the {model} speech model is already installed")); @@ -1217,9 +1217,7 @@ fn review_text(segs: &[&Seg], fps: f64) -> String { /// serves it, and a new run is stored under that range. The output depends only on the piece. fn run_piece(bin: &Path, p: &Piece, model: &str, lang: &str, hint: &str, fps: f64) -> Result, String> { let known = if p.mix { None } else { source_key(&p.path, p.stream, model, lang, hint) }; - // An entry with no segments is never served: it is a silent answer, and audible audio gets - // heard again (below) instead of trusting it. - let cached = |dir: &Path| read_exact(dir, p.from, p.to).filter(|raw| has_segments(raw)); + let cached = |dir: &Path| read_exact(dir, p.from, p.to); if let Some(raw) = known.as_deref().and_then(|k| cached(&cache_dir().join(k))) { return raw_to_segs(&raw, p, fps); } @@ -1244,19 +1242,12 @@ fn run_piece(bin: &Path, p: &Piece, model: &str, lang: &str, hint: &str, fps: f6 fs::write(&wav.0, wav_bytes(&samples)).map_err(|e| temp_write_error(&wav.0, "writing", e))?; let raw = run_stt(bin, &wav.0, model, lang, hint, p.from, &p.label)?; let segs = parse_raw(&raw)?.len(); - if segs > 0 { - write_entry(&dir, p.from, p.to, &raw); - } + write_entry(&dir, p.from, p.to, &raw); // A segment is one phrase the model timed (start and end), padding included; words are counted inside them. eprintln!("transcript {}: done, {segs} segment(s) from the model (phrases with their own start and end, padding included)", p.label); raw_to_segs(&raw, p, fps) } -/// True when a cached raw output holds at least one segment. -fn has_segments(raw: &str) -> bool { - parse_raw(raw).is_ok_and(|v| !v.is_empty()) -} - /// True for audio with no sound in it at all (below -80 dBFS). fn is_silent(samples: &[f32]) -> bool { samples.iter().all(|s| s.abs() < 1e-4) @@ -3828,10 +3819,7 @@ mod tests { } #[test] - fn an_empty_cached_answer_is_not_served() { - assert!(!has_segments("")); - assert!(!has_segments("\n")); - assert!(has_segments(r#"{"start":0.0,"end":1.0,"text":"hi","words":[]}"#)); + fn digital_silence_is_silent() { assert!(is_silent(&[0.0; 16])); assert!(!is_silent(&[0.0, 0.2, 0.0])); }