Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/context/ROUTE_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ return 404; successful deletion returns 204.
|---|---|---|
| `/ws/booth/{booth_id}` | optional JWT via `?token=` + cookies (`session_token` or `user_token`) | See WebSocket Protocol in `REPOSITORY_CONTEXT.md` |
| `/ws/captions/{booth_id}` | optional JWT via `?token=` (always validated; user tokens must belong to an active account issued after its session cutoff); listener token, join code (cookie or `?code=`), or current user session required when event has `listener_join_code`; events without a join code retain public caption access with an anonymous connection cap | Receives `booth:state` (listener-safe live/lock status, sent on connect and on change), `caption`, and `translated_caption` messages; listener captions feed. Supports `{event_slug}-{room_id}-{language_code}` (`floor-{room_id}` allowed only in unauthenticated dev). Closes 1011 when the session lookup fails so clients can retry |
| `/ws/tts/{room_id}/{language_code}/{booth_id}` | JWT query param, session/user token, or listener join code cookie (a cookie code spends the shared join-code budget when connecting); current account state and session cutoff checked for user tokens, credentials rechecked at most every 5 s while bundles are sent (a listener-code recheck only compares the code and spends no budget); a failed DB check withholds the bundle | Receives framed binary bundle messages (1-byte version `0x01`, 4-byte big-endian header length `L`, `L`-byte UTF-8 JSON header, optional 24 kHz 16-bit mono PCM payload) |
| `/ws/tts/{room_id}/{language_code}/{booth_id}` | JWT query param, session/user token, or listener join code cookie (a cookie code spends the shared join-code budget when connecting); current account state and session cutoff checked for user tokens, credentials rechecked at most every 5 s while bundles are sent (a listener-code recheck only compares the code and spends no budget); a failed DB check withholds the bundle | Receives framed binary bundle messages (1-byte version `0x01`, 4-byte big-endian header length `L`, `L`-byte UTF-8 JSON header, optional 24 kHz 16-bit mono PCM payload). `?streaming=1` advertises support for `audio_chunk_index` and `audio_final` in opt-in incremental mode; older clients receive atomic audio |
| `/ws/demo/live` | none; same-origin `Origin` required (else 403/4003); refused (close 1008) when the Admin or `LIVE_DEMO_ENABLED=false` switched it off; per-server session cap (close 1013), per-IP hourly budget by ASGI client address (close 1008), daily minutes cap (`daily_limit`, close 1008; a running try ends with `done` reason `daily_limit`) and time limit, all from `/admin/live-demo/` (env defaults until saved) | Home-page live demo on local models (faster-whisper → NLLB → Supertonic), or in room mode on a room's own speech, translation and voice services with its event's keys (the speech service's `run_stream` reads the audio through `AudioPipe`; nothing is saved to the room). Client sends JSON `start` `{source, targets (≤ admin limit), listen, names, glossary:[{term, lang (all or a target), translation}] (≤10)}`, then binary 16 kHz s16le mono frames (≤1 s each), optional `listen`, and `stop`. Server sends `status`, `ready`, `notice` (a speech service's status line), `partial`/`final` captions, `translation`, `audio` header followed by one binary 24 kHz PCM frame, `error`, and `done` before closing |

---
Expand Down
14 changes: 10 additions & 4 deletions .agents/context/TRANSCRIPTION_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Jitsi Meet Floor Conference
| `portal/transcription/__init__.py` | Re-exports public API; holds `shared_http_client` (AsyncClient) |
| `portal/transcription/constants.py` | `ProviderEnum`, `ALLOWED_MODELS` dict |
| `portal/transcription/worker.py` | `transcription_worker`, `start_transcription_worker`, `stop_transcription_worker`; `active_workers`/`active_processes` dicts |
| `portal/transcription/aggregator.py` | `CaptionAggregator`, `CaptionState` — partial/final merging, forced finalization |
| `portal/transcription/aggregator.py` | `CaptionAggregator`, `CaptionState` — partial/final merging, forced finalization; opt-in stable-prefix commits, deadlines anchored to buffered text, immutable rolling source windows; shutdown joins active handlers and deadlines; Deepgram/ElevenLabs reconnects discard unconfirmed tails while flushing settled text |
| `portal/transcription/stable_prefix.py` | Bounded agreement/holdback ledger for revisable STT hypotheses; maps committed boundaries through source edits without replay |
| `portal/transcription/realtime_turns.py` | Orders OpenAI transcript items by committed-audio predecessor IDs before releasing partials/finals |
| `portal/transcription/providers/base.py` | `TranscriptionProvider` ABC, `ProviderConfig`, `BoothTranscriptionState`, `pcm_to_wav`, `get_api_key` |
| `portal/transcription/providers/local.py` | `LocalProvider` — faster-whisper CPU; model cache + LRU eviction |
| `portal/transcription/providers/openai.py` | `OpenAIProvider` — whisper-1 (REST) + gpt-4o-realtime (WebSocket) |
Expand All @@ -90,13 +92,17 @@ Jitsi Meet Floor Conference
| `portal/transcription/providers/elevenlabs.py` | `ElevenLabsProvider` — scribe_v2_realtime WebSocket; glossary source terms (`load_glossary_terms` with ElevenLabs' 100-term / 1,000-character limits, read once per stream, honours `floor_ai_vocabulary_enabled`) sent as repeated `keyterms`; reconnects without them if refused |
| `portal/translations/worker.py` | `TranslationWorker`: per-language translation dispatch (or one multi-target batch for capable registered models), timeouts and delivery; `ENGINES` maps each provider to its `TranslationEngine`; `scheduler_for` gives each local model, the self-hosted server and each event on a hosted provider one shared `TranslationScheduler` |
| `portal/translations/scheduler.py` | `TranslationScheduler`: at most `max_concurrency` engine calls in flight; rooms take turns, then languages, and a room below its fair share of slots goes first; per-language limits (2 running, 15 admitted in all, waiting or running). Batched worker segments use one shared source-stream channel (same 2-running/15-admitted bounds) rather than one queue entry per language.; listeners are rechecked on engine admission and stale jobs obey the configured lag budget. The live demo's local translations use it too |
| `portal/translations/engine.py` | `TranslationEngine` interface (`translate_batch`, `translate_text`), `Language`, `TranslationContext`, `EngineKind`; the worker calls engines only through it |
| `portal/translations/engine.py` | `TranslationEngine` interface (`translate_batch`, `translate_text`, append-only `translate_stream`), `Language`, `TranslationContext` (persona/style/glossary and rolling source fields), `EngineKind`; batch-only engines emit one completed streaming result |
| `portal/translations/stream_http.py` | Hosted translation SSE framing and text-only deltas for OpenAI-compatible, Anthropic and Gemini APIs; completion markers required, no retry after output |
| `portal/translations/rolling_context.py` | Immutable bounded previous-source/lookahead snapshot passed via task context to LLM prompts |
| `portal/translations/streaming.py` | Opt-in translation/TTS concurrency, coalesced unread text bounded by the segment character cap, independent text/PCM delivery and legacy atomic fallback; engine admission stays in the worker and is not held by downstream delivery waits |
| `portal/translations/providers/` | Backends: `LocalProvider` (NLLB-200, MADLAD-400 and M2M100 through CTranslate2, an engine itself) and the prompt-based cloud providers, wrapped by `ProviderEngine` in `base.py` |
| `portal/translations/constants.py` | Translation providers and the hosted models offered for each; the self-hosted list comes from the registry |
| `portal/translations/registry.py` | `TranslationModel`: one entry per self-hosted model (engine kind, pinned Hugging Face repo and revision, ISO 639-1 to model language codes, memory, capabilities, licence, and how the languages are tagged: NLLB-style language tokens or a MADLAD `<2xx>` target tag), tokenizer type when the repository names none; `get_translation_model()` |
| `portal/translations/prompts.py` | Contextual prompt construction incorporating room AI persona and style instructions |
| `portal/translations/vocabulary.py` | AI interpretation vocabulary & glossary resolution, CSV import/export, and matching |
| `portal/tts/worker.py` | `TTSWorker`, buffers punctuation, chunks text, routes to a TTS provider, pushes raw PCM binary to `tts_manager` |
| `portal/tts/worker.py` | `synthesize` collects an atomic result; `synthesize_stream` forwards provider PCM chunks through a callback |
| `portal/tts/text_stream.py` | Bounded spoken phrases from append-only text, with punctuation, word/character limits and a deadline that does not cancel provider token reads |
| `portal/tts/providers/` | `TTSProvider` ABC + factory; `DeepgramTTSProvider` (Aura WebSocket), `ElevenLabsTTSProvider` (Eleven v4 Turbo → v4 over `/v1/text-to-dialogue/stream`, `pcm_24000`) and `SupertonicTTSProvider` (in-process ONNX, 44.1k→24k resample) |
| `portal/tts/constants.py` | `DEEPGRAM_VOICE_MAPPING` (language→Aura voice) plus Supertonic preset voices, language map, and supported languages; `ELEVENLABS_DEFAULT_VOICE_ID` and `ELEVENLABS_SUPPORTED_LANGS` (Eleven v4, Thai included) |

Expand Down Expand Up @@ -160,7 +166,7 @@ Cancels the asyncio Task and awaits it; removes from state dicts.

| Method | Input | Behavior |
|---|---|---|
| `handle_partial(booth_id, text)` | streaming partial | Broadcasts `{type:"caption", status:"partial", text}`. Force-finalizes if ≥50 words or ≥15 seconds in same utterance |
| `handle_partial(booth_id, text)` | streaming partial | Broadcasts `{type:"caption", status:"partial", text}`. Legacy mode force-finalizes at ≥50 words/≥15 seconds; opt-in mode commits agreed prefixes with lookahead and a deadline |
| `handle_final(booth_id, text)` | completed utterance | Broadcasts `{type:"caption", status:"final", text}`; resets state |
| `handle_chunk(booth_id, text)` | Whisper text chunk | Appends to buffer; splits on sentence boundary (`[.?!]+`); broadcasts `final` for each sentence, `partial` for remainder |
| `handle_clear(booth_id)` | silence/endpoint | Broadcasts `{type:"caption", status:"clear"}` |
Expand Down
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ MEDIAMTX_AUTH_HOOK_SECRET=
# SELF_HOSTED_LLM_BASE_URL=http://localhost:11434/v1
# SELF_HOSTED_LLM_MODELS=llama3.2,qwen2.5:7b
# SELF_HOSTED_LLM_API_KEY=
# Enable only for templates whose content excludes unmarked reasoning.
# SELF_HOSTED_LLM_STREAMING=false
# Requests in flight at once across all rooms; further ones wait, with rooms taking turns.
# Match the server's parallelism (for Ollama, OLLAMA_NUM_PARALLEL).
# SELF_HOSTED_LLM_CONCURRENCY=4
Expand All @@ -144,6 +146,14 @@ MEDIAMTX_AUTH_HOOK_SECRET=
# backed-up language catches up with the speaker instead of falling behind. 0 = never skip.
# TRANSLATION_MAX_LAG_SECONDS=4

# Opt-in incremental interpretation; validate provider latency and translation quality first.
# See docs/streaming-interpretation.md. Defaults retain atomic speech delivery.
# STREAMING_INTERPRETATION_ENABLED=false
# STREAMING_CAPTION_MIN_WORDS=4
# STREAMING_CAPTION_HOLDBACK_WORDS=2
# STREAMING_CAPTION_MAX_WORDS=12
# STREAMING_CAPTION_MAX_SECONDS=2

# ── LibreTranslate (self-hosted, machine-translation) ────────────────────────
# LibreTranslate (https://libretranslate.com) is a self-hosted machine-translation
# server. Only the operator sets the URL, so event owners can't aim requests at
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/listener-browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
paths:
- ".github/workflows/listener-browser.yml"
- "tests/listener_channel_switch_browser.py"
- "tests/listener_streaming_browser.py"
- "tests/browser_harness.py"
- "portal/routers/listener.py"
- "portal/booth_identity.py"
Expand All @@ -21,10 +22,15 @@ on:
- "portal/static/js/whep-listener.js"
- "portal/static/js/listener-event.js"
- "portal/static/js/program-delivery.js"
- "portal/static/js/streaming-delivery.js"
- "portal/static/js/tts-parser.js"
- "portal/static/js/audio-scheduler.js"
- "portal/static/js/brutal-select.js"
- "portal/websockets/**"
- "portal/translations/**"
- "portal/tts/**"
- "portal/transcription/**"
- "portal/config.py"
- "portal/join_code_limit.py"
- "portal/auth.py"
- "pyproject.toml"
Expand All @@ -37,6 +43,7 @@ on:
paths:
- ".github/workflows/listener-browser.yml"
- "tests/listener_channel_switch_browser.py"
- "tests/listener_streaming_browser.py"
- "tests/browser_harness.py"
- "portal/routers/listener.py"
- "portal/booth_identity.py"
Expand All @@ -49,10 +56,15 @@ on:
- "portal/static/js/whep-listener.js"
- "portal/static/js/listener-event.js"
- "portal/static/js/program-delivery.js"
- "portal/static/js/streaming-delivery.js"
- "portal/static/js/tts-parser.js"
- "portal/static/js/audio-scheduler.js"
- "portal/static/js/brutal-select.js"
- "portal/websockets/**"
- "portal/translations/**"
- "portal/tts/**"
- "portal/transcription/**"
- "portal/config.py"
- "portal/join_code_limit.py"
- "portal/auth.py"
- "pyproject.toml"
Expand Down Expand Up @@ -99,6 +111,11 @@ jobs:
LISTENER_ARTIFACT_DIR: listener-browser-artifacts
BROWSER_TEST_RUNS: ${{ inputs.runs || '1' }}
run: uv run --with playwright==1.58.0 python tests/listener_channel_switch_browser.py
- name: Stream interpretation through the real listener with stubbed AI endpoints
if: always() && !cancelled()
env:
PYTHONPATH: .
run: uv run --with playwright==1.58.0 python tests/listener_streaming_browser.py
- name: Upload listener rehearsal recording and screenshots
if: always()
uses: actions/upload-artifact@v7.0.2
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ jobs:
node --check portal/static/js/booth-reconnect.js
node --check portal/static/js/mic-activity.js
node --check portal/static/js/whep-listener.js
node --check portal/static/js/listener-event.js
node --check portal/static/js/program-delivery.js
node --check portal/static/js/streaming-delivery.js
node --check portal/static/js/admin.js
node --check portal/static/js/attendance.js
node --check portal/static/js/booth-detail.js
Expand All @@ -307,6 +310,7 @@ jobs:
- name: run node tests
run: |
node tests/test_audio_scheduler.js
node tests/test_program_delivery.mjs
node tests/test_tts_parser.js
node --test tests/test_demo_modal.js
node tests/test_listener_event.js
Expand Down
Loading