|
|
@@ -14,7 +14,7 @@ def _result(text="hello world"):
|
|
|
|
|
|
|
|
|
def test_jsonl_includes_level_and_reason(tmp_path):
|
|
|
- sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path))
|
|
|
+ sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path), jsonl=True)
|
|
|
sink.emit(_result(), 2.5, rms=0.041234, reason="pause")
|
|
|
|
|
|
files = list(tmp_path.glob("*.jsonl"))
|
|
|
@@ -29,7 +29,7 @@ def test_jsonl_includes_level_and_reason(tmp_path):
|
|
|
|
|
|
|
|
|
def test_jsonl_includes_transcribe_seconds(tmp_path):
|
|
|
- sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path))
|
|
|
+ sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path), jsonl=True)
|
|
|
sink.emit(_result(), 2.5, rms=0.041234, reason="pause", transcribe_s=0.81234)
|
|
|
|
|
|
record = json.loads(next(tmp_path.glob("*.jsonl")).read_text().splitlines()[0])
|
|
|
@@ -37,13 +37,22 @@ def test_jsonl_includes_transcribe_seconds(tmp_path):
|
|
|
|
|
|
|
|
|
def test_transcribe_seconds_omitted_when_unknown(tmp_path):
|
|
|
- sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path))
|
|
|
+ sink = TranscriptSink(stdout=False, jsonl_dir=str(tmp_path), jsonl=True)
|
|
|
sink.emit(_result(), 2.5, rms=0.041234, reason="pause")
|
|
|
|
|
|
record = json.loads(next(tmp_path.glob("*.jsonl")).read_text().splitlines()[0])
|
|
|
assert "transcribe_s" not in record
|
|
|
|
|
|
|
|
|
+def test_jsonl_disabled_writes_nothing(tmp_path, capsys):
|
|
|
+ """jsonl=False keeps transcripts off disk even when jsonl_dir is set."""
|
|
|
+ sink = TranscriptSink(stdout=True, jsonl_dir=str(tmp_path), jsonl=False)
|
|
|
+ sink.emit(_result(), 1.0, rms=0.02, reason="pause")
|
|
|
+
|
|
|
+ assert "hello world" in capsys.readouterr().out
|
|
|
+ assert list(tmp_path.glob("*.jsonl")) == []
|
|
|
+
|
|
|
+
|
|
|
def test_stdout_includes_level_and_reason(capsys):
|
|
|
sink = TranscriptSink(stdout=True, jsonl_dir=None)
|
|
|
sink.emit(_result(), 1.0, rms=0.02, reason="end_of_turn")
|
|
|
@@ -55,7 +64,7 @@ def test_stdout_includes_level_and_reason(capsys):
|
|
|
|
|
|
|
|
|
def test_empty_text_is_skipped(tmp_path, capsys):
|
|
|
- sink = TranscriptSink(stdout=True, jsonl_dir=str(tmp_path))
|
|
|
+ sink = TranscriptSink(stdout=True, jsonl_dir=str(tmp_path), jsonl=True)
|
|
|
sink.emit(_result(text=""), 1.0, rms=0.02, reason="pause")
|
|
|
|
|
|
assert capsys.readouterr().out == ""
|
|
|
@@ -70,6 +79,7 @@ def test_saves_wav_when_enabled(tmp_path):
|
|
|
sink = TranscriptSink(
|
|
|
stdout=False,
|
|
|
jsonl_dir=str(logs),
|
|
|
+ jsonl=True,
|
|
|
save_audio=True,
|
|
|
audio_dir=str(tmp_path / "audio"),
|
|
|
sample_rate=16000,
|
|
|
@@ -110,6 +120,7 @@ def test_single_timestamp_per_emit(tmp_path, monkeypatch):
|
|
|
sink = TranscriptSink(
|
|
|
stdout=False,
|
|
|
jsonl_dir=str(logs),
|
|
|
+ jsonl=True,
|
|
|
save_audio=True,
|
|
|
audio_dir=str(tmp_path / "audio"),
|
|
|
sample_rate=16000,
|
|
|
@@ -163,6 +174,7 @@ def test_failed_audio_save_is_non_fatal(tmp_path, monkeypatch, capsys, caplog):
|
|
|
sink = TranscriptSink(
|
|
|
stdout=True,
|
|
|
jsonl_dir=str(logs),
|
|
|
+ jsonl=True,
|
|
|
save_audio=True,
|
|
|
audio_dir=str(tmp_path / "audio"),
|
|
|
sample_rate=16000,
|