feat: reconcile speaker identities through OpenRouter audio

Short chunk overlaps often contain only one participant, so returning
speakers receive new transcript IDs. MAI can also split one voice into
several IDs within a single request, which overlap stitching cannot fix.

Add an opt-in audio comparison pass: --speakers N selects Gemini 3.8 Flash
with a known count, and --speaker-model allows another compatible model.
Keep request-local identities separate, select up to three clean excerpts
per ID, and compare all excerpts in one OpenRouter request. Gemini uses
Google AI Studio because the Vertex backend limits prompts to one audio
file. No local model or extra Python dependency is required.

Only reconcile identities whose sample assignments agree. Preserve
uncertain identities separately, reject incomplete or malformed replies,
and retain the original words and timestamps. Bound sample count and
request size, clip sampling to the real audio duration, and extend worker
cleanup and buffered output to the comparison step. Document the sampled
method's limitations and additional provider request.

Test Plan:
- python3 -B -m unittest -v: all 82 tests passed, including real MP3
  encoding with fake transcription/comparison responses and cancellation.
- bash -n transcribe: passed.
- git diff --cached --check: passed.
- Live API and voice accuracy unverified: this workspace could not access
  the configured 1Password credential. Mocked responses prove pipeline
  behavior, not model accuracy on the supplied recording.
This commit is contained in:
ddidderr committed 2026-09-12 10:04:56 +02:00
1 parent 1d03dcd587
commit 138c796399
9 files changed
+988 -19

No files matched your search

+6 -2
View File
@@ -24,11 +24,15 @@
- `chunks.py`: upload boundaries and ordered overlap stitching.
- `subtitles.py`: timestamp validation and SRT cue formatting.
- `transcript.py`: readable text paragraphs and speaker markers.
- `diarization.py`: optional OpenRouter audio sample comparison and speaker ID reconciliation.
- `test_*.py` and `tests/fake_provider.py`: local regression tests without real
credentials or provider requests.
Keep the CLI and its three Python helpers together. Preserve transcript order
Keep the CLI and its four Python helpers together. Preserve transcript order
and emit stdout only after all chunks and output conversion succeed. Provider
speaker IDs are request-local; reuse transcript IDs across requests only with
supporting overlap evidence. Keep chunk details out of the final transcript.
supporting overlap or explicit shared-audio comparison evidence. Voice comparison
must preserve transcription text and timestamps, validate complete sample
assignments, and leave uncertain or conflicting identities separate. Keep chunk
details out of the final transcript.
Progress, processing details, and errors belong on stderr.