|
|
@@ -98,3 +98,32 @@ def test_save_audio_without_samples_is_safe(tmp_path):
|
|
|
|
|
|
assert not (tmp_path / "audio").exists()
|
|
|
|
|
|
+
|
|
|
+def test_failed_audio_save_is_non_fatal(tmp_path, monkeypatch, capsys, caplog):
|
|
|
+ import stt_daemon.output as output
|
|
|
+
|
|
|
+ def boom(*args, **kwargs):
|
|
|
+ raise OSError("disk full")
|
|
|
+
|
|
|
+ monkeypatch.setattr(output, "write_wav", boom)
|
|
|
+
|
|
|
+ logs = tmp_path / "logs"
|
|
|
+ sink = TranscriptSink(
|
|
|
+ stdout=True,
|
|
|
+ jsonl_dir=str(logs),
|
|
|
+ save_audio=True,
|
|
|
+ audio_dir=str(tmp_path / "audio"),
|
|
|
+ sample_rate=16000,
|
|
|
+ )
|
|
|
+ with caplog.at_level("WARNING"):
|
|
|
+ sink.emit(
|
|
|
+ _result(), 1.0, rms=0.3, reason="pause", audio=np.zeros(1600, dtype=np.float32)
|
|
|
+ )
|
|
|
+
|
|
|
+ assert "hello world" in capsys.readouterr().out
|
|
|
+ record = json.loads(next(logs.glob("*.jsonl")).read_text().splitlines()[0])
|
|
|
+ assert record["text"] == "hello world"
|
|
|
+ assert "audio" not in record
|
|
|
+ assert "Failed to save audio" in caplog.text
|
|
|
+
|
|
|
+
|