Add speaker-attributed meeting transcription

This commit is contained in:
2026-06-12 12:18:35 +00:00
parent 7516e0ad61
commit 8fd5e5b464
7 changed files with 571 additions and 13 deletions
+74
View File
@@ -20,6 +20,7 @@ from openrouter_client import (
_transcribe_chunk,
summarize,
transcribe,
transcribe_tracks,
)
@@ -226,3 +227,76 @@ def test_chat_completion_reports_provider_fallback_when_all_summarizers_fail(mon
assert "Summarization failed across providers" in message
assert "OpenRouter summarization returned empty content" in message
assert "direct OpenAI summarization fallback skipped" in message
def test_transcribe_tracks_labels_each_speaker_block(tmp_path: Path, monkeypatch):
alice = tmp_path / "alice.wav"
bob = tmp_path / "bob.wav"
alice.write_bytes(b"alice audio")
bob.write_bytes(b"bob audio")
calls = []
async def fake_transcribe(path: str) -> str:
calls.append(Path(path).name)
return {
"alice.wav": "I finished the API work.",
"bob.wav": "I will test it tomorrow.",
}[Path(path).name]
monkeypatch.setattr(openrouter_client, "transcribe", fake_transcribe)
result = asyncio.run(
transcribe_tracks(
[
{"display_name": "Alice", "path": str(alice)},
{"display_name": "Bob", "path": str(bob)},
]
)
)
assert result == "[Alice]\nI finished the API work.\n\n[Bob]\nI will test it tomorrow."
assert calls == ["alice.wav", "bob.wav"]
def test_transcribe_tracks_skips_failed_tracks_when_at_least_one_succeeds(tmp_path: Path, monkeypatch):
alice = tmp_path / "alice.wav"
bob = tmp_path / "bob.wav"
alice.write_bytes(b"alice audio")
bob.write_bytes(b"bob audio")
async def fake_transcribe(path: str) -> str:
if Path(path).name == "bob.wav":
raise RuntimeError("provider down")
return "Alice spoke."
monkeypatch.setattr(openrouter_client, "transcribe", fake_transcribe)
result = asyncio.run(
transcribe_tracks(
[
{"display_name": "Alice", "path": str(alice)},
{"display_name": "Bob", "path": str(bob)},
]
)
)
assert result == "[Alice]\nAlice spoke."
def test_transcribe_tracks_raises_when_no_tracks_produce_text(tmp_path: Path, monkeypatch):
alice = tmp_path / "alice.wav"
alice.write_bytes(b"alice audio")
async def fake_transcribe(_path: str) -> str:
return ""
monkeypatch.setattr(openrouter_client, "transcribe", fake_transcribe)
try:
asyncio.run(transcribe_tracks([{"display_name": "Alice", "path": str(alice)}]))
except RuntimeError as exc:
message = str(exc)
else:
raise AssertionError("Expected transcribe_tracks failure")
assert "Speaker-track transcription produced no text" in message