Ship live translations
with confidence
A production-ready full-stack Node.js + React application for seamless EN↔RU↔UK live auto-detect translation with voice synthesis.
⚙
Installation
Set up the project locally with Docker, Redis, and LibreTranslate in minutes.
▦
Architecture
Understand the STT → Translation → TTS pipeline and real-time Socket.io communication.
▶
Live Translation
Stream from YouTube or microphone with automatic EN/RU/UK language detection and voice output.
📜
Biblical Simulator
Test the full pipeline with AI-generated biblical passages in King James, Church Slavonic, or Ukrainian style.
🎤
Voice Training
Clone custom voices from microphone recordings or YouTube videos using ElevenLabs IVC.
Prerequisites
●
Node.js 20+
Runtime for backend and build tools
●
Docker + Docker Compose
For Redis and LibreTranslate services
●
yt-dlp + ffmpeg
Required for YouTube audio extraction
●
ElevenLabs API Key
For speech-to-text and text-to-speech
Clone & Configure
git clone https://github.com/Pzharyuk/live-translator-node.git && cd live-translator-node
cp .env.example .env
Edit .env and set your API key:
ELEVENLABS_API_KEY=sk-your-key-here
ADMIN_PASSWORD=your-secure-password
Start Infrastructure
# Start Redis + LibreTranslate
docker compose -f docker-compose.local.yml up -d
# Wait for LibreTranslate to download language models (~500 MB)
docker logs -f $(docker ps -qf "name=libretranslate") 2>&1 | grep -i "running"
Start Backend
cd backend
npm install
npm run dev # nodemon watches for changes
Start Frontend
cd frontend
npm install
npm run dev # Vite hot-reload on localhost:5173
✓
You're all set!
Open http://localhost:5173 — log in with user / changeme and you will be redirected to /translate. Admin panel: http://localhost:5173/admin (admin password: admin123).
System Overview
Frontend
React 19 + Vite
Socket.io Client
Web Audio API
↔
Backend
Express + Socket.io
TypeScript
Service Layer
ElevenLabs
Scribe v2 (STT)
TTS Streaming
Voice Cloning
Translation
Google Translate (Cloud API)
LibreTranslate (self-hosted)
DeepL (premium API)
Claude / Anthropic (AI)
Redis
Feature Flags
Settings Store
Google Gemini
Biblical Simulator
Sermon Generation
Voice Training Text
DeepL
Free & Pro tiers
Auto endpoint detection
Church Directory
Central church registry
Live selector feed
Data Flow
1 Audio Input (Mic / YouTube / Simulator)
↓
2 PCM 16-bit LE @ 16kHz via Socket.io chunks
↓
3 ElevenLabs Scribe v2 WebSocket STT
↓
4 Commit Merge Buffer 2.5s VAD aggregation
↓
5 Translation Provider Google / LibreTranslate / DeepL / Claude
↓
6 ElevenLabs TTS Voice synthesis streaming
↓
7 Audio Playback Queued with 600ms pause
Key Architecture Decisions
Two-layer Language Detection
LibreTranslate's /detect endpoint returns 0-confidence for short Cyrillic phrases. The app uses script-based pre-detection (Unicode 0x0400–0x04FF = Cyrillic) combined with ElevenLabs Scribe's language_code output for reliable EN/RU/UK auto-detection.
VAD Commit Merging
Voice Activity Detection can fire aggressively on speaker breathing. Commits are buffered for 2.5 seconds before translation to merge fragments into meaningful phrases.
Feature Flag Merging
YAML config defaults are merged with Redis runtime overrides. Redis values take priority, falling back to YAML if Redis is unavailable.
API Key Hierarchy
Keys resolve in order: Runtime Cache → Redis → Config File → Empty. This allows hot-swapping keys without restarts.
Multi-church Isolation
Multi-church: Each church runs its own isolated deployment (own backend, Redis, database) at translate-<church>.hgministry.com. A church selector on the broadcast page lets listeners switch churches; the menu is fed by a central directory that updates live without touching running broadcasts. Audio, transcripts, and translations never cross between churches.
Connection Lifecycle
- Client sends
start_session with source type (mic or youtube) and optional voiceId
- Backend opens a WebSocket to
wss://api.elevenlabs.io/v1/speech-to-text/realtime
- For YouTube: spawns
yt-dlp | ffmpeg child processes to extract PCM audio
- For Microphone: awaits
audio_chunk events from the frontend
Audio Streaming
Audio chunks are sent to Scribe as JSON messages:
{
"message_type": "input_audio_chunk",
"audio_base_64": "UklGR..." // PCM 16-bit LE, 16kHz, mono
}
Scribe Responses
| Response Type | Meaning | Action |
partial_transcript |
Live partial text (speculative) |
Emitted as non-final transcript event |
committed_transcript |
VAD fired — complete phrase |
Buffered for commit merge window |
Commit Merge Buffer
After receiving a committed_transcript, the backend waits 2.5 seconds (COMMIT_MERGE_MS) to collect additional commits before translating. This prevents fragmented translations from aggressive VAD.
Stability Timeout
If VAD stalls (no new commits), a 3.5 second fallback timer (STABILITY_TIMEOUT_MS) fires to translate whatever new text has accumulated, preventing indefinite silence.
Text Validation
Before translation, text is validated against EN/RU/UK character regex patterns. This filters out hallucinated text from the STT model (common with silence or background noise).
Provider Chain
The system supports three translation providers with automatic fallback:
Default
LibreTranslate
Self-hosted, no API key required. Runs in Docker alongside the app. Best for privacy and cost.
Premium
DeepL
High-quality translations. Supports both free and paid API tiers. Auto-detects endpoint.
AI
Claude
Anthropic's Claude for context-aware translations. Uses claude-haiku-4-5 for speed.
Fallback Logic
1. Try primary provider (admin-selected)
2. If primary fails → try configured fallback
3. If fallback fails → try LibreTranslate (last resort)
4. If all fail → emit error event
Language Detection
The app uses a two-layer auto-detection approach:
Layer 1: Script-based Pre-detection
Before calling any translation API, the backend checks Unicode character scripts:
- Cyrillic characters (Unicode 0x0400–0x04FF) → if >50% of matched letters are Cyrillic, detected as Russian
- Latin characters → detected as English
- This avoids low-confidence results from LibreTranslate's
/detect endpoint on short text
Layer 2: STT Language Code
When the auto_language_detect flag is enabled, ElevenLabs Scribe returns a language_code with each transcript commit. The backend uses this to correctly route EN/RU/UK without relying solely on script detection.
Note: For LibreTranslate, both Russian and Ukrainian Cyrillic text is passed with source ru since LibreTranslate handles Ukrainian text acceptably via the Russian model. DeepL and Claude providers distinguish Ukrainian natively and handle uk as a proper source language.
Language Gating
Detected languages are checked against the admin-approved pool. If a detected language isn't in the allowed set, the translation is rejected to prevent hallucinated language outputs.
TTS Pipeline
After translation, the text is sent to ElevenLabs TTS:
const stream = await client.textToSpeech.stream(voiceId, {
text: translatedText,
model_id: "eleven_multilingual_v2",
output_format: "mp3_44100_128",
voice_settings: {
stability: 0.5,
similarity_boost: 0.75,
style: 0.0,
speed: 1.0,
use_speaker_boost: true
}
});
Audio Delivery
TTS audio is streamed to a Buffer, then emitted as a base64-encoded MP3 via the tts_audio Socket.io event.
Frontend Playback Queue
The frontend maintains an audio queue to prevent overlapping playback:
- Received
tts_audio events are queued
- Each segment plays to completion before the next starts
- A configurable pause (600ms default) is inserted between segments
- The pause duration is controlled by
tts_segment_pause_ms (adjustable in admin)
Microphone Input
- User selects "Mic" tab and chooses a TTS voice
- Browser captures audio via Web Audio API's
ScriptProcessor
- PCM 16-bit LE at 16kHz sample rate sent to backend via Socket.io
- Backend pipes audio to ElevenLabs Scribe v2 Realtime WebSocket
- Language auto-detected (EN/RU/UK), text translated and synthesized
- TTS audio returned and played back with inter-segment pauses
YouTube Input
- User pastes a YouTube URL (live stream or video)
- Backend spawns
yt-dlp | ffmpeg child processes
- Audio extracted as PCM stream (16kHz, 16-bit LE, mono)
- Piped to Scribe v2, same pipeline as microphone
- Stream ends when YouTube content ends or user stops
User Interface
The user view features a dark cavern theme with:
- Waveform visualizer — Canvas-based bar chart with orange gradient and cyan tips
- Transcript display — White translated text scrolls upward with fade masks
- Partial transcript — Shown in italic orange while STT is processing
- Source tabs — Toggle between Mic and YouTube (controlled by feature flags)
How It Works
The backend uses yt-dlp and ffmpeg as child processes to extract audio from YouTube URLs:
yt-dlp (best audio) → ffmpeg (PCM 16kHz 16-bit LE mono) → Scribe v2
Supported Sources
- Live streams — Translates in real-time as the stream progresses
- Regular videos — Processes the full audio track
- Any URL supported by yt-dlp (YouTube, etc.)
Requirements
Both yt-dlp and ffmpeg must be installed and available in the system PATH. On macOS:
brew install yt-dlp ffmpeg
⚠
Feature Flag Required
YouTube input is controlled by the youtube_input feature flag. Enable it in the admin panel to show the YouTube tab in the user view.
Overview
The Biblical Transcript Simulator is an admin-only feature that generates biblical text passages using Google's Gemini API (gemini-2.5-flash), then routes them through the full translation pipeline. This provides a hands-free way to test STT → Translation → TTS without a live audio source.
Language Styles
| Language | Style | Example |
en |
King James English |
"In the beginning was the Word..." |
ru |
Church Slavonic Russian |
"В начале было Слово..." |
uk |
Traditional Ukrainian |
"На початку було Слово..." |
Flow
- Admin selects language (EN/RU/UK)
- Backend calls Gemini 2.5 Flash with streaming
- Gemini generates 6-8 biblical passages, 3-5 sentences each
- Stream is buffered until 140+ characters AND complete sentences
- Chunks emitted with 1800ms smooth pacing between them
- Each chunk flows through the standard pipeline:
- Emitted as
transcript (isFinal: true)
- Auto-translated via configured provider
- TTS synthesized and audio returned
- Frontend plays audio with standard inter-segment pause
💡
Feature Flag
Enable biblical_simulator in the admin feature flags panel. The Gemini API key is configured via the GEMINI_API_KEY environment variable or set at runtime in the admin API Keys panel.
Overview
Voice Training uses ElevenLabs' Instant Voice Cloning (IVC) API to create custom voices from audio samples. Once cloned, the voice appears in the voice selector immediately.
From Microphone
- Open the Voice Training section in the admin panel
- Click Generate Text to get an AI-generated reading passage (via Gemini) — gives the speaker natural, phonetically diverse text to read aloud
- Record multiple audio clips using your browser microphone while reading the generated text
- Provide a name for the voice
- Clips are uploaded to ElevenLabs IVC API
- Cloned voice is available for TTS immediately
- Click Preview Voice to hear the cloned voice speak a sample sentence via TTS
From YouTube
- Paste a YouTube URL in the Voice Training section
- Backend extracts N × 30-second clips via
yt-dlp + ffmpeg
- Clips are uploaded to ElevenLabs IVC API
- Resulting voice is stored in your ElevenLabs account
⚠
ElevenLabs Account
Cloned voices are stored in your ElevenLabs account, not locally. Ensure your plan supports voice cloning.
Concepts
| Concept | Description |
| Active Language Pair |
The current pair used for translation (e.g., EN ↔ RU, EN ↔ UK, or RU ↔ UK). Set by admin. |
| Available Languages |
The pool of languages viewers can select from (if user_language_selector is enabled). |
Admin Controls
- Change the active language pair via the admin panel
- Changes broadcast to all connected clients in real-time
- Manage the available languages pool for viewer selection
Viewer Selection
When the user_language_selector feature flag is enabled, viewers can override the admin-set language pair by selecting their own preferred languages from the available pool.
Overview
Two people can video call each other through the app, each speaking their own language. The app transcribes, translates, and synthesizes speech in real-time so each participant hears the other in their language.
Feature flag: Video call is gated behind the video_translation flag. Enable it in the admin panel or set video_translation: true in your YAML config.
How It Works
- Create a room — Person A selects their language, picks a TTS voice, and clicks "Create Room". A 6-character room code is generated.
- Share the code — Person A shares the room code with Person B (copy button provided).
- Join the room — Person B enters the code, selects their language and TTS voice, and clicks "Join".
- WebRTC connection — The app establishes a peer-to-peer video connection via WebRTC (signaled through Socket.io). Video flows directly between browsers.
- Audio translation — Each participant's microphone audio is simultaneously:
- Sent to the peer via WebRTC (but muted on their end)
- Captured as PCM chunks and sent to the backend via Socket.io for STT
- Translation pipeline — Each participant has their own independent Scribe STT session. Transcribed text is translated to the other participant's language, then synthesized via ElevenLabs TTS and sent back to the peer.
- Playback — The peer hears the TTS translation instead of the raw audio. Translated transcript is displayed below the video.
Architecture
Person A (Browser) Server Person B (Browser)
├─ getUserMedia ├─ Socket.io ├─ getUserMedia
├─ WebRTC P2P ═══video═══►│ (signaling) ◄═══ ├─ WebRTC P2P
│ │ │
├─ PCM chunks ──Socket.io─►├─ ScribeA(STT) │
│ │ ↓ translate │
│ │ ↓ TTS ───────────►├─ Plays TTS
│ │ │
│ Plays TTS ◄─────────────├─ ScribeB(STT) ◄───├─ PCM chunks
│ (remote video muted) │ ↓ translate │ (remote video muted)
└──────────────────────────┴────────────────────┘
Socket Events
| Event | Direction | Purpose |
video_create_room | C→S | Create a new room with language + voice |
video_room_created | S→C | Returns the 6-char room code |
video_join_room | C→S | Join an existing room |
video_room_joined | S→C | Sent to both participants, triggers WebRTC |
video_signal_offer/answer/ice | C↔S | WebRTC signaling relay |
video_audio_chunk | C→S | PCM audio for STT processing |
video_transcript | S→C | Transcript sent to the speaker |
video_translation | S→C | Translation sent to the listener |
video_tts_audio | S→C | TTS audio sent to the listener |
video_leave_room | C→S | Leave the room |
video_room_closed | S→C | Notify peer when other leaves |
Room Lifecycle
- Rooms are stored in Redis with key
video_room:{code} and a 4-hour TTL
- Maximum 2 participants per room
- When one participant disconnects, the other is notified and the call ends
- Scribe sessions are automatically cleaned up on disconnect
The Mac Audio Agent has moved to its own public repository:
github.com/Pzharyuk/live-translator-agent
It is a lightweight Node.js daemon that runs as a macOS LaunchAgent and streams microphone audio to the live-translator backend via Socket.io — eliminating the need to open a browser for the Remote Audio Source role.
Pre-shared key authentication
Any socket that emits register_audio_source must present the server's pre-shared key in the Socket.IO handshake (auth.agentPsk). This stops random clients from connecting to the backend and impersonating an agent.
- Server: set
AGENT_PSK (env var) — surfaces as auth.agent_psk in application.yaml. An empty value disables enforcement and logs a warning on every registration.
- Mac daemon: add
agentPsk to ~/.config/live-translator-agent/config.json (or set the AGENT_PSK env var — env wins).
- Browser
/audio-source: paste the key into the new Agent Pre-Shared Key field; it is stored in localStorage on that device only and travels in the handshake (never in event payloads).
- Mismatch behaviour: server logs
register_audio_source REJECTED ... invalid or missing PSK, emits agent_auth_error to the client, then disconnects.
Overview
/projector is a dedicated output route for the room screen — a projector, a confidence monitor, or a ProPresenter web element. It shows only the translated broadcast text: no original transcript, no live partial, no header, status pill, mute button, or schedule chrome. The newest line appears at the bottom and the whole stack rises as more text arrives.
The page is silent. It never plays TTS audio — sound comes from the room PA. This lets it run fullscreen on a booth machine indefinitely without fighting the sound system for control of playback.
The route itself requires no login, matching /broadcast, so it can be opened directly on a projector computer that has no admin session. Visibility is instead controlled by the projector feature flag.
⚠
Feature Flag Required
/projector is gated by the projector feature flag, which ships false in production. Enable it per-deployment in the admin Feature Flags panel before pointing a projector at the URL.
The admin Projector Output section is gated by the same flag: with the flag off the section is not rendered at all, and it appears the moment the flag is toggled on — no page reload needed.
Adaptive-Creep Scrolling
Rather than jumping line-by-line or scrolling at a fixed speed, the stack drifts continuously so the congregation reads a flowing column instead of a cursor jump:
- Base creep — a slow continuous drift,
18 px/s by default (?speed=).
- Catch-up — speed increases proportionally to how far behind the speaker the text has fallen, targeting a close-the-gap time of
tau seconds (?tau=, default 4).
- Blur cap — speed never exceeds
130 px/s, so catching up never makes the text unreadable.
- Idle freeze — the moment nobody is speaking and there is no backlog left, motion stops completely rather than idling forward.
- Desync snap — a reconnect or a history replay after rejoin can leave the text far behind the live edge; once the backlog is large enough that crawling back would take minutes, the view snaps straight to the live edge instead.
- Centred while short — before the text fills the frame (the start of a service, or just after a clear) the stack is centred vertically rather than clinging to the top. Text is centred horizontally in both layouts.
Prayer & Song Pauses
When the broadcast is paused for prayer or song, the text fades out and a quiet message (“Prayer in progress” / “Song in progress”) fades in over the same spot. The scroll position is frozen, not reset, so when the pause ends the text fades back in exactly where the reader left off.
URL Parameters
All parameters are optional and independently clampable — an out-of-range value (typed by hand, or a leftover from a previous config) is clamped to the nearest valid bound rather than breaking the page.
| Parameter | Default | Description |
bg |
dark |
Backdrop: dark (app theme), transparent, or green (chroma-key). With layout=lower3, green fills only the band — everything above it stays transparent, so ProPresenter keys a defined lower-third region instead of the whole frame. |
layout |
full |
full fills the frame; lower3 confines text to a band pinned to the bottom — one line tall by default, with the text creeping continuously through it. |
size |
1 |
Font-size multiplier applied to the responsive base text size. |
band |
auto |
Lower-third band height. Left off (or auto) the band is exactly one line tall, derived from the same expression as the font size so it tracks size and the screen's aspect ratio. Give it a number to override in vh. Ignored when layout=full. |
speed |
18 |
Base scroll creep, px/sec. Clamped between 2 and 130. |
tau |
4 |
Seconds the engine targets to close any backlog before it falls back to the base creep. |
ProPresenter Setup
- Add the
/projector URL as a web element in ProPresenter, sized 1920×1080.
- Use
layout=lower3 so the text stays confined to the bottom band — one line tall unless band says otherwise — and bg=green to fill that band with a solid chroma-key green. The area above the band stays transparent, so only the band needs keying.
- Chroma-key the green in ProPresenter's compositing so only the text remains over your lyric/camera background.
⚠
Why green, not transparent
ProPresenter 7's web element has historically been unreliable about honouring page transparency — several versions composite it onto opaque black instead. bg=green is the recommended path for that reason; bg=transparent is available but should be verified on the actual playout machine before relying on it.
Admin “Projector Output” Panel
The admin panel's Projector Output section builds the launch URL and controls a running projector without editing query strings by hand:
- URL builder — layout, backdrop, text size, and band height (when in lower-third; leave the field blank for a one-line band), reflected live in the copyable link.
- Live Speed drag bar — a 2–130 px/s slider that retunes an already-open projector window instantly, so an operator can tune the creep by eye while watching the actual screen.
- Copy link — copies the absolute
/projector URL with the current options encoded.
- Launch button — opens the projector in a new window. Once displays have been detected it launches fullscreen directly onto the chosen one instead.
- Close projector window — stops the output without hunting the fullscreen window down on the other screen. The request travels over
BroadcastChannel, not the handle window.open returned, so it still works after the admin page has been reloaded. There is no delivery receipt, so the button confirms only “Close sent” — it is harmless to press when nothing is open, and the panel never claims to know whether a projector is running.
- Detect displays — lists the physical displays attached to the current machine so you can pick one. Chrome only shows its permission prompt in response to a click, so this is a button rather than something that happens on page load: press it and choose Allow. Once granted, the list appears automatically on every later visit from that browser.
- Settings are remembered — layout, backdrop, text size, band height, and speed are saved in the browser's
localStorage and restored on the next visit, so the projector only has to be configured once per booth machine. Saved values are re-validated on read and clamped to the same ranges the URL accepts. The selected display is deliberately not saved — screens come and go, so detection re-runs each time.
💡
If no display list appears
The panel always states which case you are in, directly under the “Displays attached to this machine” heading:
- “Click Detect displays…” — permission has not been asked for yet. Press the button and choose Allow.
- “Detection was dismissed…” — the prompt was closed without granting. Press the button again.
- “Display selection is blocked…” — permission was denied. Chrome will not ask again from a click; re-enable Window management in the site settings behind the icon at the left of the address bar.
- “Only one display is attached…” — detection worked and there is genuinely nothing to choose between. Connect the projector, then press Detect displays again.
- “Display selection needs a Chromium browser…” — Safari and Firefox do not implement the Window Management API. Copy the URL or use Open in new window and press F11 on the projector display.
⚠
Three limitations to know before service
A hand-opened window cannot be closed remotely. Browsers only let a script close a window a script opened — so Close projector window genuinely closes a projector started with Launch, but cannot close one opened by pasting the URL into a tab. That window is not left unchanged: it stops showing the service text, leaves fullscreen, and displays “Projector output stopped — you can close this window”, then drops out of the broadcast viewer count. Reload the page to resume output. Like the Live Speed bar, this only reaches projector windows in the same browser on the same machine.
Display list is local. The picker only enumerates displays physically attached to the machine the admin page is open on — it cannot see or drive a projector connected to a different computer. It also requires the browser's Window management permission, granted through the Detect displays button.
Live Speed bar is same-browser only. It pushes updates over BroadcastChannel, which only reaches a projector window opened from that same browser. A projector running on another machine keeps whatever speed was in its ?speed= parameter at page load — the live bar cannot retune it.
Feature Flags
Feature flags control which routes and UI sections are available. Defaults are set in application.yaml and can be overridden at runtime via Redis. The admin API endpoint GET/POST /admin/flags allows dynamic toggling without restarting the server.
| Flag |
Default |
Description |
youtube_input |
true |
Enable YouTube live stream broadcast source (admin can paste a YouTube URL). |
mic_input |
true |
Enable microphone audio input for the admin broadcaster. |
auto_language_detect |
true |
Automatically detect source language from incoming audio instead of requiring manual selection. |
user_language_selector |
false |
Allow viewers to change the translation language pair from the UI (otherwise admin-only). |
audio_device_selector |
true |
Show audio device dropdown so admins can select which mic/speaker to use. |
video_translation |
true |
Enable the /video route for peer-to-peer video calls with real-time translation. |
video_voice_cloning |
false |
Premium: show Clone Voice button in video lobby to create custom voices from recordings. |
remote_audio_source |
false |
Enable /audio-source route for headless remote audio relay agents. |
agent_audio_source |
false |
Show connected remote audio sources section in the admin broadcast panel. |
stream_input |
false |
Enable HTTP/Icecast audio stream source (church Icecast endpoint, etc.). |
broadcast |
false |
Enable /broadcast route — public receiver page that shows translated transcripts & TTS audio. |
translate |
false |
Enable /translate route — live translator page for private mic/YouTube translation sessions. |
projector |
false |
Enable /projector route for congregation screens & ProPresenter integration. |
Storage & API
Feature flags are stored in Redis under keys prefixed with flag:. On startup, the server merges application.yaml defaults with any Redis overrides. When an admin toggles a flag via the API, the new value is persisted to Redis and broadcast to all connected clients via Socket.IO so UI updates appear in real-time.
Admin API Endpoints
GET /admin/flags
Response: { "flags": { "youtube_input": true, "mic_input": true, ... } }
POST /admin/flags/:flag
Body: { "value": true }
Response: { "flag": "youtube_input", "value": true }
GET /admin/flags/:flag
Response: { "flag": "youtube_input", "value": true }
All three endpoints require JWT authentication (admin session cookie). Toggling a flag emits a feature_flags Socket.IO event to all connected clients, allowing the frontend to adapt immediately without refresh.
File Structure
| File | Purpose |
config/application.yaml |
Base defaults for all environments |
config/application-local.yaml |
Local development overrides (localhost URLs) |
config/application-prod.yaml |
Production overrides (Docker service names) |
The APP_ENV environment variable (local or prod) determines which overlay file is loaded on top of the base config.
Full Configuration Reference
server:
port: 3001
cors_origin: "http://localhost:5173"
elevenlabs:
api_key: "${ELEVENLABS_API_KEY}"
default_voice_id: "kxj9qk6u5PfI0ITgJwO0"
tts_model: "eleven_multilingual_v2"
tts_settings:
stability: 0.5
similarity_boost: 0.75
style: 0.0
speed: 1.0
use_speaker_boost: true
stt_model: "scribe_v2"
anthropic:
api_key: "${ANTHROPIC_API_KEY}"
deepl:
api_key: "${DEEPL_API_KEY}"
libretranslate:
url: "http://libretranslate:5000"
api_key: ""
redis:
host: "redis"
port: 6379
password: ""
feature_flags:
youtube_input: true
mic_input: true
auto_language_detect: true
user_language_selector: false
audio_device_selector: true
video_translation: false
video_voice_cloning: false
broadcast: false
audio:
sample_rate: 16000
channels: 1
chunk_duration_ms: 250
translation:
source_lang: "auto"
target_lang_en: "en"
target_lang_ru: "ru"
provider: "libretranslate"
fallback: "libretranslate"
Environment Variable Interpolation
YAML values using ${VAR_NAME} syntax are automatically replaced with the corresponding environment variable at startup.
TTS Settings
Real-time text-to-speech configuration for ElevenLabs voice synthesis. All settings can be modified at runtime via the admin panel without restarting the server.
API Endpoints
GET /admin/tts-settings
Response: { "settings": TtsSettings }
POST /admin/tts-settings
Request: { partial TtsSettings object }
Response: { "settings": updated TtsSettings }
Configuration Table
| Setting |
Range |
Default |
Description |
stability |
0.0 – 1.0 |
0.5 |
Voice consistency vs. variation; higher = more consistent pronunciation. |
similarity_boost |
0.0 – 1.0 |
0.75 |
How closely the output matches the selected voice; higher = closer match. |
style |
0.0 – 1.0 |
0.0 |
Voice style emphasis (exaggeration); 0 = neutral, higher = more expressive. |
speed |
0.5 – 2.0 |
1.0 |
Playback speed multiplier; 1.0 = normal, < 1.0 = slower, > 1.0 = faster. |
use_speaker_boost |
true ¦ false |
true |
Enable speaker boost for enhanced clarity and presence in output. |
Configuration File
Default settings in application.yaml:
elevenlabs:
api_key: "${ELEVENLABS_API_KEY}"
default_voice_id: "kxj9qk6u5PfI0ITgJwO0"
tts_model: "eleven_multilingual_v2"
tts_settings:
stability: 0.5
similarity_boost: 0.75
style: 0.0
speed: 1.0
use_speaker_boost: true
stt_model: "scribe_v2_realtime"
Related Settings
- TTS Output Format— MP3 (44.1 kHz, 128 kbps) for browser playback; PCM 16 kHz for internal loopback testing.
- TTS Model—
eleven_multilingual_v2 supports 29+ languages; eleven_flash_v2_5 used for low-latency video calls.
- Pipeline Buffer— See
tts_pipeline.initial_buffer_segments and tts_pipeline.low_water_hold_ms in application.yaml.
Voice Management
Voices are fetched from ElevenLabs and optionally filtered to an admin-maintained allowlist. Use the admin panel to scan available voices and restrict which ones users can select.
GET /admin/voices
Response: { "voices": [...] }
GET /admin/available-voices
Response: { "voiceIds": string[] | null }
POST /admin/available-voices
Request: { "voiceIds": string[] }
Response: { "voiceIds": string[] }
STT Timing Settings
Fine-tune speech recognition chunk timing and VAD parameters:
| Setting |
Range |
Default |
Description |
commit_merge_ms |
0 – 10000 |
2500 |
Buffer VAD commits for this many ms before translating to merge fragments. |
stability_timeout_ms |
0 – 5000 |
2000 |
Dispatch unchanged partial text after this delay (fallback when VAD is slow). |
tts_segment_pause_ms |
0 – 2000 |
0 |
Pause between TTS audio segments on the frontend (ms). |
max_accumulation_ms |
1000 – 30000 |
8000 |
Force-dispatch accumulated words after this duration during continuous speech. |
vad_threshold |
0.0 – 1.0 |
0.5 |
Voice Activity Detection sensitivity; higher = stricter noise filter. |
vad_silence_threshold_secs |
0.1 – 3.0 |
1.5 |
Silence duration (seconds) before VAD triggers a commit. |
min_speech_duration_ms |
50 – 500 |
100 |
Ignore speech shorter than this; prevents noise triggers. |
min_silence_duration_ms |
50 – 500 |
100 |
Minimum silence gap (ms) recognized as a break in speech. |
flush_on_sentence_boundary |
true ¦ false |
true |
Split commits at sentence endings (.?!;) instead of flushing all at once. |
min_chars_before_dispatch |
10 – 500 |
40 |
Accumulate at least this many characters before dispatching to translation. |
GET /admin/stt-timing
Response: { "settings": SttTimingSettings }
POST /admin/stt-timing
Request: { partial SttTimingSettings object }
Response: { "settings": updated SttTimingSettings }
Video Call Settings
Separate STT/TTS tuning for video calls (lower latency, different stability requirements):
| Setting |
Range |
Default |
Description |
stability_ms |
100 – 2000 |
500 |
Wait for stable partial before translating (lower for video responsiveness). |
commit_merge_ms |
0 – 200 |
50 |
Merge VAD commits over shorter window (faster turnaround for conversation). |
translation_provider |
libretranslate ¦ claude ¦ deepl ¦ google |
claude |
Translation backend for this call (may differ from broadcast provider). |
GET /admin/video-settings
Response: VideoCallSettings
POST /admin/video-settings
Request: { partial VideoCallSettings object }
Response: updated VideoCallSettings
Notes
- Persistence— All settings are stored in Redis (setting:tts_settings, setting:stt_timing, setting:video_call_settings) and survive pod restarts.
- Runtime Changes— Admin panel updates apply instantly to all active broadcasts; no service restart required.
- Fallback— If Redis is unavailable, the server uses the
application.yaml defaults.
- Backward Compatibility— Missing settings in Redis fall back to config file values; partial updates merge instead of replace.
Speech-to-Text Timing Configuration
The STT timing settings control how the speech recognition engine buffers and dispatches transcribed text for translation. Adjusting these values tunes the balance between responsiveness and translation accuracy.
Settings Reference
| Setting |
Default |
Description |
commit_merge_ms |
2500 |
Buffer VAD commits (ms) before translating—merges short fragments into larger chunks for fewer translation calls. |
stability_timeout_ms |
2000 |
Wait for stable partial text (ms) before translating when it stops changing. |
tts_segment_pause_ms |
0 |
Pause (ms) between TTS audio segments; sent to frontend for playback pacing. |
max_accumulation_ms |
8000 |
Maximum time (ms) to accumulate words during continuous speech before force-dispatching for translation. |
vad_threshold |
0.5 |
Voice Activity Detection threshold (0–1); higher = stricter noise filtering. |
vad_silence_threshold_secs |
1.5 |
Seconds of silence required before VAD fires a commit to the server. |
min_speech_duration_ms |
100 |
Ignore speech shorter than this (ms)—filters out clicks and pops. |
min_silence_duration_ms |
100 |
Minimum silence gap (ms) between detected speech segments. |
flush_on_sentence_boundary |
true |
Split and dispatch at sentence boundaries (.?!;) instead of all at once. |
min_chars_before_dispatch |
40 |
Minimum characters required before a chunk is dispatched—prevents tiny fragments from translating. |
Tuning Guide
- Faster response: Lower
max_accumulation_ms (e.g., 4000–5000), reduce commit_merge_ms (e.g., 1000–1500), and lower min_chars_before_dispatch (e.g., 20–30).
- Better accuracy: Increase
max_accumulation_ms (e.g., 10000–12000) to gather larger contexts, raise min_chars_before_dispatch (e.g., 60–80), and increase commit_merge_ms (e.g., 3000–4000).
- Reduce background noise: Raise
vad_threshold (e.g., 0.6–0.8) and increase min_speech_duration_ms (e.g., 150–200).
- Catch short phrases: Lower
vad_silence_threshold_secs (e.g., 0.8–1.0) and reduce min_silence_duration_ms (e.g., 50–75).
- Sentence-aware dispatch: Enable
flush_on_sentence_boundary to emit complete sentences instead of arbitrary chunks, improving translation context.
API
GET /admin/stt-timing—Retrieve current STT timing settings.
curl -X GET http://localhost:3001/admin/stt-timing \
-H "Cookie: auth=<token>"
Response:
{
"settings": {
"commit_merge_ms": 2500,
"stability_timeout_ms": 2000,
"tts_segment_pause_ms": 0,
"max_accumulation_ms": 8000,
"vad_threshold": 0.5,
"vad_silence_threshold_secs": 1.5,
"min_speech_duration_ms": 100,
"min_silence_duration_ms": 100,
"flush_on_sentence_boundary": true,
"min_chars_before_dispatch": 40
}
}
POST /admin/stt-timing—Update one or more STT timing settings (persisted to Redis).
curl -X POST http://localhost:3001/admin/stt-timing \
-H "Cookie: auth=<token>" \
-H "Content-Type: application/json" \
-d '{
"max_accumulation_ms": 6000,
"min_chars_before_dispatch": 50,
"vad_threshold": 0.6
}'
Response:
{
"settings": {
"commit_merge_ms": 2500,
"stability_timeout_ms": 2000,
"tts_segment_pause_ms": 0,
"max_accumulation_ms": 6000,
"vad_threshold": 0.6,
"vad_silence_threshold_secs": 1.5,
"min_speech_duration_ms": 100,
"min_silence_duration_ms": 100,
"flush_on_sentence_boundary": true,
"min_chars_before_dispatch": 50
}
}
Authentication: All admin endpoints require a valid JWT cookie (ADMIN_SESSION). The JWT payload must contain is_admin: true OR a non-empty permissions array. Endpoints requiring specific permissions will reject requests lacking those permissions with a 403 status.
API Keys Management
Retrieve the status of all configured API keys (ElevenLabs, Anthropic, DeepL, LibreTranslate, Google, YouTube).
Update one or more API keys. Only keys present in the request body are updated; others remain unchanged.
Body: {
"elevenlabs": "sk-...",
"anthropic": "sk-ant-...",
"deepl": "...:fx",
"libretranslate": "...",
"google": "AIzaSy...",
"youtube": "AIzaSy..."
}
Voice Management
Scan and return all available ElevenLabs voices with their IDs, names, categories, and preview URLs. Logs which voices are newly discovered.
Get the list of voice IDs that viewers are allowed to select from (admin-curated pool). Returns null if all voices are allowed.
Update the list of allowed voice IDs for viewers. Broadcasts the updated pool to all connected clients in real-time.
Body: {
"voiceIds": ["JBFqnCBsd6RMkjVDRZzb", "aXr5XQjlmeJ4xmF3EUZR"]
}
Generate TTS audio for a text snippet using a specified voice. Returns PCM or MP3 binary audio data for playback testing.
Body: {
"text": "This is a test sentence",
"voiceId": "JBFqnCBsd6RMkjVDRZzb",
"format": "mp3"
}
Voice Training & Instant Voice Cloning
Clone a voice from browser mic recordings. Accepts base64-encoded audio blobs (WebM, WAV, etc.) and trains a new ElevenLabs instant voice.
Body: {
"name": "John Preacher",
"clips": ["data:audio/webm;base64,...", "data:audio/webm;base64,..."],
"mimeType": "audio/webm"
}
Clone a voice from a YouTube URL. Uses yt-dlp & ffmpeg to extract N×30-second audio clips, then uploads them for voice training.
Body: {
"name": "Speaker Name",
"youtubeUrl": "https://www.youtube.com/watch?v=...",
"clipCount": 3,
"startOffset": 0
}
Feature Flags
Retrieve all feature flags merged from YAML defaults & Redis overrides.
Get the current value of a specific feature flag.
Set a feature flag value and broadcast the updated flags to all connected clients via Socket.IO.
TTS & STT Settings
Retrieve current TTS settings (stability, similarity boost, style, speed, speaker boost).
Update TTS settings. Only provided fields are updated; omitted fields remain unchanged.
Body: {
"stability": 0.5,
"similarity_boost": 0.75,
"style": 0.0,
"speed": 1.0,
"use_speaker_boost": true
}
Retrieve STT (speech-to-text) timing settings including VAD thresholds, commit delays, and accumulation timeouts.
Update STT timing settings to fine-tune transcription responsiveness & translation dispatch behavior.
Body: {
"commit_merge_ms": 2500,
"stability_timeout_ms": 2000,
"tts_segment_pause_ms": 0,
"max_accumulation_ms": 8000,
"vad_threshold": 0.5,
"vad_silence_threshold_secs": 1.5,
"min_speech_duration_ms": 100,
"min_silence_duration_ms": 100,
"flush_on_sentence_boundary": true,
"min_chars_before_dispatch": 40
}
Languages & Translation
Get the current active language pair (source, target) for broadcast translation.
Set the active language pair & broadcast the change to all connected viewers in real-time.
Body: {
"languages": ["en", "ru"]
}
Get the pool of languages that viewers are allowed to select from (admin-curated).
Update the available language pool & broadcast both the pool & current active pair to all clients.
Body: {
"languages": ["en", "ru", "uk"]
}
Retrieve the currently active translation provider & list of available providers (google, deepl, claude, libretranslate).
Switch the active translation provider at runtime.
Body: {
"provider": "google"
}
Get the currently selected Claude model & list of available Claude models for translation.
Switch which Claude model is used when the translation provider is set to 'claude'.
Body: {
"model": "claude-3-5-sonnet-20241022"
}
Audio Device Management
Retrieve the admin-selected audio input device (overrides viewer's local selection) with its ID & label.
Set the admin-controlled audio input device & broadcast the selection to all connected viewers via Socket.IO.
Body: {
"deviceId": "default",
"label": "Built-in Microphone"
}
Stream & HTTP Audio
Get the saved HTTP/Icecast audio stream URL that persists across broadcasts (e.g., church audio endpoint).
Set or clear the saved HTTP audio stream URL. Empty string clears the saved value. Non-empty values must be valid http(s) URLs.
Body: {
"url": "http://icecast.example.com:8000/live.mp3"
}
Video Call Settings
Retrieve video call STT/TTS settings (stability timeout, commit merge delay, translation provider for calls).
Update video call translation settings. Partial updates are supported.
Body: {
"stability_ms": 500,
"commit_merge_ms": 50,
"translation_provider": "claude"
}
Sermon Generation
Generate a biblical sermon excerpt using Gemini Flash. Accepts optional language & sentence count parameters.
Body: {
"apiKey": "AIzaSy...",
"language": "en",
"sentences": 5
}
Broadcast Schedule
Retrieve the list of scheduled broadcast events with their source configs, times, & auto-start parameters.
Update the entire broadcast schedule. Each event can specify source (mic, youtube, biblical, remote, stream), voice, languages, & optional source-specific settings.
Body: {
"events": [
{
"id": "evt_1",
"title": "Sunday Service",
"datetime": "2025-01-26T10:00:00Z",
"description": "Weekly broadcast",
"source": "youtube",
"youtubeUrl": "https://www.youtube.com/watch?v=...",
"voiceId": "JBFqnCBsd6RMkjVDRZzb",
"allowedLanguages": ["en", "ru"]
}
]
}
YouTube Integration
Retrieve the configured YouTube channel ID & whether it came from environment or was set via API.
Update the YouTube channel ID for live stream discovery.
Body: {
"channelId": "UCxxxxxxxxxxxxxxxxxxxxxx"
}
Lookup active live streams from a YouTube channel. Optionally accepts a custom channelId query parameter. Uses YouTube Data API if configured, falls back to yt-dlp.
Moderation & Monitoring
Retrieve hallucination detection statistics (false transcripts filtered from translation pipeline).
Clear the hallucination detection log.
Get the list of custom filler words that are stripped from source transcripts before translation (e.g., 'uh', 'um', 'угу').
Update the list of custom filler words to strip from transcripts on the fly during in-flight broadcasts.
Body: {
"words": ["uh", "um", "like", "угу", "э-э-э"]
}
Retrieve translation activity log (original → translated text pairs, timings, providers).
Clear the translation activity log.
List all active video call rooms with participants. Participant tokens are stripped from the response for security.
Force-close an active video call room by code, disconnecting all participants.
Get real-time snapshot of broadcast TTS pipeline queue depths & stream stats (pending, translated, consumer lag).
Session History & Export
Retrieve list of all broadcast sessions from PostgreSQL (started_at, ended_at, source, voice, transcript counts).
Get detailed session data including full transcript array with seq, timestamps, detected language, original & translated text, & timings.
Export session transcripts in multiple formats. Query parameter format can be 'json' (default), 'csv', or 'txt'. Returns attachment download.
User Management
List all users (requires user_management permission). Password hashes & avatar data are stripped.
Update a user's admin status & role assignments (requires user_management permission).
Body: {
"isAdmin": false,
"roleIds": ["role_1", "role_2"]
}
Reset a user's password (requires user_management permission). Password must be at least 6 characters.
Body: {
"password": "newpassword123"
}
Delete a user account (requires user_management permission). Cannot delete your own account.
Roles & Permissions
List all available permissions that can be assigned to roles (requires user_management permission).
List all custom roles with their assigned permissions (requires user_management permission).
Create a new custom role with specified permissions (requires user_management permission). Role name must be unique.
Body: {
"name": "Moderator",
"permissions": ["broadcast_control", "user_management"]
}
Update an existing role's name & permissions (requires user_management permission).
Body: {
"name": "Moderator",
"permissions": ["broadcast_control"]
}
Delete a custom role (requires user_management permission).
Public Endpoints (No Auth)
Note: This endpoint is unguarded — returns the Anthropic API key. Used by frontend for client-side sermon generation. Keep the returned key secret.
SDK
Uses the official @elevenlabs/elevenlabs-js SDK (v2). The client is lazy-loaded on first use.
Speech-to-Text (Scribe v2 Realtime)
Connects via native WebSocket to wss://api.elevenlabs.io/v1/speech-to-text/realtime. Handles:
- VAD-based commit buffering with configurable merge window
- Stability timeout fallback for stalled VAD
- Text validation (EN/RU/UK character regex filtering)
- Partial and final transcript emission
Text-to-Speech
Uses client.textToSpeech.stream() with the eleven_multilingual_v2 model. Audio is collected into a Buffer and emitted as base64 MP3.
Voice Management
client.voices.getAll() — fetches all voices from account
- Admin can filter which voices are available to viewers
- Voice cloning via IVC API (from recordings or YouTube)
Key File
backend/src/services/elevenlabs.service.ts
Provider Details
Google Translate
Google Cloud Translation API v2. Fast (~200ms), deterministic, and reliable. Requires GOOGLE_TRANSLATE_API_KEY with the Cloud Translation API enabled in Google Cloud Console. Ensure the API key has no HTTP referrer restrictions (server-side requests have no referrer).
File: backend/src/services/google-translate.service.ts
LibreTranslate
Self-hosted in Docker. No API key required by default. Provides language detection and translation via REST API.
File: backend/src/services/libretranslate.service.ts
DeepL
Premium translation API. Auto-detects free vs. paid endpoint based on the API key format.
File: backend/src/services/deepl.service.ts
Claude (Anthropic)
AI-powered translation using claude-haiku-4-5 for speed. Includes language detection and auto-flip logic.
File: backend/src/services/claude-translate.service.ts
Routing
Provider routing is handled by backend/src/services/translation.provider.ts:
- Try admin-selected primary provider
- On failure, try configured fallback provider
- LibreTranslate is always the last-resort fallback
Connection
Uses ioredis with automatic retry strategy. Falls back to in-memory/YAML defaults if Redis is unavailable.
Key Patterns
| Pattern | Example | Purpose |
flag:<name> |
flag:youtube_input |
Feature flag boolean values |
setting:<name> |
setting:tts_settings |
JSON settings objects |
Key File
backend/src/services/redis.service.ts
Local Development
Use docker-compose.local.yml for Redis and LibreTranslate only (backend/frontend run natively):
docker compose -f docker-compose.local.yml up -d
Production
Use docker-compose.yml for all services:
docker compose up -d --build
Services
| Service | Image | Port | Notes |
| frontend |
node:24-alpine + Nginx |
80 (exposed) |
Serves React build, proxies API/WS to backend |
| backend |
node:24-alpine |
3001 (internal) |
Express + Socket.io server |
| redis |
redis:7-alpine |
6379 (internal) |
Feature flags and settings store |
| libretranslate |
libretranslate/libretranslate |
5000 (internal) |
Self-hosted translation engine |
Configuration
ELEVENLABS_API_KEY=sk-your-production-key
ADMIN_PASSWORD=strong-secure-password
FRONTEND_URL=https://translate.example.com
APP_ENV=prod
REDIS_PASSWORD=redis-secret
Deploy
docker compose up -d --build
Reverse Proxy
When running behind Nginx or another reverse proxy:
- Set
LISTEN_PORT in .env (e.g., 8080)
- Proxy pass to
localhost:8080
- Important: Ensure WebSocket upgrades are forwarded for the
/socket.io/ path
server {
listen 443 ssl;
server_name translate.example.com;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
Monitoring
# Check all services
docker compose ps
# View backend logs
docker compose logs -f backend
# Health check
curl http://localhost:3001/api/health