Repository navigation
fix(transcription): keep booth caption sequences across handovers so translations don't stop (#1365) - #1433
Conversation
…ssasia#1365) Interpreter booth captions took seq from a counter inside each CaptionAggregator, so every handover, WHIP reconnect or restart started again at 1. Listeners drop seq below the one they expect, so translated speech stopped after the first handover. Store the counter on the booth (booths.caption_seq, migration 051) and allocate it atomically with UPDATE ... RETURNING, like Room.floor_caption_seq from fossasia#1062. A per-booth lock keeps allocation and broadcast in order when an old and new aggregator overlap. Database failures publish text without a seq, and deleted booths drop pending finals, matching the floor. Room-less aggregators (home-page demo) keep the in-memory counter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Sorry @ArnavBallinCode, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 2 days and 20 hours by commenting |
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Pre-merge checks:
|
|
Hi @ArnavBallinCode, thanks for your contribution! Before we can review this PR, please add a short screencast video showing the change working (before/after where relevant). If no video is added within 72 hours, this PR will be closed automatically. You are welcome to reopen it or submit a new PR once you have the screencast. |
|
Note 🤖 Copilot SDK in VS Code responding on behalf of ArnavBallinCode This PR has a migration-chain blocker: its |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Note 🤖 Copilot SDK in VS Code responding on behalf of @ragini-angarkar Merged current |
Description
After an interpreter handover or reconnect, translated speech stopped for listeners on that booth. Each
CaptionAggregatornumbered booth captions from its own in-memory_seq_counter, so every new worker (handover, WHIP reconnect, provider retry, portal restart) started again atseq1. The listener drops anything below theseqit expects next, so all later booth translations were discarded. Floor captions were already fixed in #1062 with the storedRoom.floor_caption_seq; booths were not.This PR uses the same approach for booths, as agreed in the issue thread. Each booth stores its own counter in a new
booths.caption_seqcolumn (migration 051). Final booth captions allocate the next value atomically withUPDATE ... RETURNING, which works on SQLite and Postgres. A per-booth lock keeps allocation and broadcast in order while an old and a new aggregator overlap during a handover. Failure handling matches the floor: if the database fails, the original text still goes out without aseq(and skips storage, translation and TTS), and pending finals for a deleted booth are dropped. Aggregators with no room (the home-page live demo) keep the in-memory counter. The listener's stale-sequence check is unchanged.Related Issue
Closes #1365
Changes Made
portal/transcription/aggregator.py: booth finals allocateseqfromDBBooth.caption_sequnderbooth_caption_lock(booth_id). The floor path (_allocate_floor_sequence,floor_caption_lock) is unchanged.portal/models.py+alembic/versions/051_add_booth_caption_seq.py: addbooths.caption_seq(Integer, not null, default 0).tests/test_booth_caption_sequences.py: regression tests for handover, reconnect and restart continuity, resuming from a stored counter, booth and floor counters staying independent, concurrent aggregators, DB outage then recovery, deleted booths, and room-less streams.TRANSCRIPTION_MAP.md,DATABASE_MAP.md, theagents.mdmigration count, and theseqfield description inwebsite/docs/api/websocket/captions.mdx.Testing
uv run pytest tests/test_booth_caption_sequences.py -qonupstream/devwith only the model column added: 6 failed, 1 passed. The handover test gets[1, 2, 1, 1]instead of[1, 2, 3, 4].uv run pytest tests/test_booth_caption_sequences.py tests/test_floor_caption_sequences.py tests/test_caption_aggregator.py tests/test_aggregator_chunk.py tests/test_deepgram_pipeline.py tests/test_youtube_caption_hooks.py tests/test_program_ingest.py -q: 98 passeduv run pytest tests/ -q: 3706 passed, 17 skippeduv run ruff check .: All checks passedDATABASE_URL=sqlite+aiosqlite:///$PWD/mig.db uv run alembic upgrade head && uv run alembic downgrade -1 && uv run alembic upgrade head: succeeded. Theboothsindexes and FKs are intact after the round trip.Proof: a booth aggregator is recreated three times (handover, then a DB reconnect standing in for a restart), and
seqkeeps rising 1→4. Each caption gets its own transcript row and its own translationseq.Screenshots (if applicable)
Not needed. This is a server-side change with no UI.
Checklist
Additional Notes
Migration number: feat(embed): support AI Voice and AI Captions channels in /embed player (#1408) #1409 also adds a
051_*migration, so whichever merges second needs to bump its number anddown_revision.Overlapping open PRs:
CaptionAggregatorand removes_seq_counter.complete_turntohandle_final.Neither changes how
seqis allocated, so a rebase should only involve textual conflicts inaggregator.pyandTRANSCRIPTION_MAP.md.fix(booth): publish again when the interpreter's WHIP connection drops #1358 reconnects the booth after a WHIP drop, which builds a new aggregator each time. This PR is what lets the sequence keep going across those reconnects. The two PRs touch different files.
Upgrade: every booth starts at 0, because the old in-memory value was never stored, the same as the floor upgrade in fix(transcription): preserve floor sequences across restarts #1062. A listener page left open across the deploy may need one reload before translated speech resumes.
Thanks to @ManojLamani, @SamanPandey-in and @Duke2nuke for working out the approach in the issue.
Created with GitHub Copilot (Copilot SDK) in VS Code.
Created with GitHub Copilot.
Summary by CodeRabbit