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).
1
Start the services
Follow the Installation guide to get Docker services, backend, and frontend running.
2
Open the Admin Panel
Navigate to http://localhost:5173/admin and enter the admin password.
3
Select a Voice
Choose a TTS voice from the dropdown. The voice list is fetched from your ElevenLabs account.
4
Test with Text
Use the free-text area in the admin panel to type a phrase. Click translate to hear the TTS output instantly.
5
Go Live
Open the user view at http://localhost:5173/translate. Select "Mic" as input, pick a voice, and click Start. Speak into your microphone and watch real-time translation appear with audio playback.
💡
Try the Biblical Simulator
For a hands-free demo, enable the biblical_simulator feature flag in admin, enter an Anthropic API key, select a language, and click "Generate". The system will produce biblical passages through the full STT → Translation → TTS pipeline.
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
LibreTranslate (self-hosted)
DeepL (premium API)
Claude / Anthropic (AI)
Redis
Feature Flags
Settings Store
Anthropic
Biblical Simulator
Claude Translation
DeepL
Free & Pro tiers
Auto endpoint detection
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 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.
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 Anthropic's Claude API, 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 provides Anthropic API key and selects language
- Backend calls Claude with streaming (uses
claude-sonnet-4-6)
- Claude 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 Anthropic API key is provided at runtime in the UI — it's never stored in config files.
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
- Record multiple audio clips using your browser microphone
- Provide a name for the voice
- Clips are uploaded to ElevenLabs IVC API
- Cloned voice is available for TTS immediately
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
Feature Flags
Feature flags control which features are enabled in the application. Defaults are defined in config/application.yaml and can be overridden at runtime via Redis. The system merges YAML defaults with any Redis overrides, allowing live toggling without redeployment.
| Flag |
Default |
Description |
youtube_input |
true |
Enable real-time translation from YouTube video audio streams. |
mic_input |
true |
Enable real-time translation from microphone input. |
auto_language_detect |
true |
Automatically detect source language during speech recognition. |
user_language_selector |
false |
Allow viewers to select target language from available pool. |
audio_device_selector |
true |
Enable audio input device selection in the UI. |
video_translation |
false |
Enable peer-to-peer video calls with real-time translation. |
video_voice_cloning |
false |
Premium feature: show Clone Voice button in video call lobby. |
Storage & Runtime Behavior
Feature flags are persisted in Redis under the key prefix flag:. On startup, the system loads YAML defaults from config/application.yaml. Any flags stored in Redis override the YAML defaults. When an admin updates a flag via the Admin API, it is immediately written to Redis and broadcast to all connected WebSocket clients via the feature_flags event, enabling live updates without redeployment.
Admin API
Feature flags are managed through the following admin endpoints:
GET /admin/flags
→ Returns merged flags (YAML defaults + Redis overrides)
→ Response: { "flags": { "youtube_input": true, "mic_input": true, ... } }
GET /admin/flags/:flag
→ Get a single flag value
→ Response: { "flag": "youtube_input", "value": true }
POST /admin/flags/:flag
→ Set a flag value and broadcast to all clients
→ Request: { "value": true }
→ Response: { "flag": "youtube_input", "value": true }
Client Reception
When a viewer connects via WebSocket, the server immediately emits the merged feature flags:
socket.emit('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
});
When an admin updates a flag, all connected clients receive the updated flags via the same event, allowing real-time UI changes.
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
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.
| Variable |
Required |
Default |
Description |
ELEVENLABS_API_KEY |
Yes |
— |
API key for ElevenLabs text-to-speech and speech-to-text services. |
ELEVENLABS_VOICE_ID |
No |
kxj9qk6u5PfI0ITgJwO0 |
Default ElevenLabs voice ID for TTS output. |
ANTHROPIC_API_KEY |
No |
— |
API key for Anthropic Claude; used for sermon generation and Claude translation provider. |
DEEPL_API_KEY |
No |
— |
API key for DeepL translation provider; required only if translation.provider = deepl. |
TRANSLATION_PROVIDER |
No |
libretranslate |
Primary translation provider: deepl, claude, or libretranslate; can be overridden in Admin UI. |
APP_ENV |
No |
local |
Application environment: local (development) or prod (Docker). |
FRONTEND_URL |
No |
http://localhost |
Frontend URL for CORS origin in production; set to actual domain (e.g., https://translate.example.com). |
LISTEN_PORT |
No |
80 |
Host port the frontend listens on. |
REDIS_PASSWORD |
No |
— |
Redis authentication password; leave empty for no authentication. |
LIBRETRANSLATE_API_KEY |
No |
— |
API key for LibreTranslate instance if authentication is required. |
ADMIN_PASSWORD |
No |
admin123 |
Admin page protection password; must be changed in production. |
APP_USERNAME |
No |
user |
User-facing login username; must be changed in production. |
APP_PASSWORD |
No |
changeme |
User-facing login password; must be changed in production. |
JWT_SECRET |
Yes |
— |
JWT secret for session cookies; generate a strong random string (e.g., openssl rand -hex 32). |
SERVER_PORT |
No |
3001 |
Backend server port (from application.yaml). |
CORS_ORIGIN |
No |
http://localhost:5173 |
CORS allowed origin (from application.yaml). |
TTS_MODEL |
No |
eleven_multilingual_v2 |
ElevenLabs TTS model ID (from application.yaml). |
STT_MODEL |
No |
scribe_v2 |
ElevenLabs speech-to-text model ID (from application.yaml). |
REDIS_HOST |
No |
redis |
Redis server hostname (from application.yaml). |
REDIS_PORT |
No |
6379 |
Redis server port (from application.yaml). |
LIBRETRANSLATE_URL |
No |
http://libretranslate:5000 |
LibreTranslate service URL (from application.yaml). |
AUDIO_SAMPLE_RATE |
No |
16000 |
Audio sample rate in Hz (from application.yaml). |
AUDIO_CHANNELS |
No |
1 |
Number of audio channels (from application.yaml). |
AUDIO_CHUNK_DURATION_MS |
No |
250 |
Audio chunk duration in milliseconds (from application.yaml). |
STABILITY |
No |
0.5 |
ElevenLabs TTS stability setting (from application.yaml). |
SIMILARITY_BOOST |
No |
0.75 |
ElevenLabs TTS similarity boost setting (from application.yaml). |
STYLE |
No |
0.0 |
ElevenLabs TTS style setting (from application.yaml). |
SPEED |
No |
1.0 |
ElevenLabs TTS speed multiplier (from application.yaml). |
USE_SPEAKER_BOOST |
No |
true |
Enable ElevenLabs speaker boost for TTS (from application.yaml). |
TTS Settings
API Endpoints
GET /admin/tts-settings
Response: { "settings": { "stability": 0.5, "similarity_boost": 0.75, "style": 0.0, "speed": 1.0, "use_speaker_boost": true } }
POST /admin/tts-settings
Body: { "stability": 0.5, "similarity_boost": 0.75, "style": 0.0, "speed": 1.0, "use_speaker_boost": true }
Response: { "settings": { /* updated values */ } }
Settings Reference
| Setting |
Range |
Default |
Description |
stability |
0.0 – 1.0 |
0.5 |
Stability of voice characteristics; lower = more variable, higher = more consistent. |
similarity_boost |
0.0 – 1.0 |
0.75 |
Boost similarity to original voice sample; higher = closer match to reference. |
style |
0.0 – 1.0 |
0.0 |
Exaggeration of voice style; 0 = neutral, higher = more pronounced expression. |
speed |
0.1 – 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 optimization for clearer, more prominent audio output. |
Configuration (application.yaml)
| Key |
Default |
Description |
elevenlabs.tts_model |
eleven_multilingual_v2 |
ElevenLabs TTS model ID for standard audio generation. |
elevenlabs.default_voice_id |
kxj9qk6u5PfI0ITgJwO0 |
Default voice used when no voice ID is specified; used by /admin/voices endpoint. |
audio.sample_rate |
16000 |
Audio sample rate in Hz for STT input and audio processing. |
audio.channels |
1 |
Number of audio channels (1 = mono). |
audio.chunk_duration_ms |
250 |
Duration of each audio chunk in milliseconds sent to STT. |
STT Timing Settings
Control latency & buffer behavior for speech-to-text processing.
| Setting |
Range |
Default |
Description |
commit_merge_ms |
0 – 10000 |
2500 |
Time to buffer VAD commits before translating; merges short fragments into single translation. |
stability_timeout_ms |
0 – 10000 |
3500 |
Time to wait for stable partial text before translating if VAD does not fire. |
tts_segment_pause_ms |
0 – 2000 |
600 |
Pause between TTS audio segments on frontend; frontend polls this value at connection. |
Video Call Settings
Separate latency tuning for video translation calls.
| Setting |
Range |
Default |
Description |
stability_ms |
0 – 2000 |
500 |
Milliseconds to wait for stable partial before translating in video calls. |
commit_merge_ms |
0 – 500 |
50 |
Milliseconds to merge VAD commits in video calls; lower = snappier response. |
translation_provider |
libretranslate | claude | deepl |
claude |
Translation provider used for video call sessions. |
API Endpoints for STT & Video Settings
GET /admin/stt-timing
Response: { "settings": { "commit_merge_ms": 2500, "stability_timeout_ms": 3500, "tts_segment_pause_ms": 600 } }
POST /admin/stt-timing
Body: { "commit_merge_ms": 2500, "stability_timeout_ms": 3500, "tts_segment_pause_ms": 600 }
Response: { "settings": { /* updated values */ } }
GET /admin/video-settings
Response: { "stability_ms": 500, "commit_merge_ms": 50, "translation_provider": "claude" }
POST /admin/video-settings
Body: { "stability_ms": 500, "commit_merge_ms": 50, "translation_provider": "claude" }
Response: { /* updated values */ }
Notes
- TTS settings are applied to all
textToSpeechStream() calls (standard & fast models).
- STT timing settings control VAD commit buffering & stability fallback for speech recognition.
- Video call settings use separate latency tuning optimized for real-time video translation.
- Settings are persisted in Redis; changes via POST endpoints override application.yaml defaults.
tts_segment_pause_ms is emitted to all connected clients on socket connection via stt_timing event.
STT Timing Settings
Configure speech-to-text (STT) recognition and translation timing to optimize responsiveness and accuracy.
| Setting |
Default |
Description |
commit_merge_ms |
2500 |
Buffer VAD commits (ms) before translating—merges short pauses into single translation. |
stability_timeout_ms |
3500 |
Wait time for stable partial text (ms) before triggering translation if VAD doesn't fire. |
tts_segment_pause_ms |
600 |
Pause between TTS audio segments (ms)—frontend uses this for playback timing. |
Tuning Guide
- Faster response: Reduce
commit_merge_ms (e.g., 1000–1500 ms) and stability_timeout_ms (e.g., 2000–2500 ms) for snappier translation.
- Fewer false positives: Increase
commit_merge_ms (e.g., 3000–4000 ms) to buffer longer and avoid translating mid-sentence pauses.
- Smooth audio playback: Adjust
tts_segment_pause_ms to match natural speech rhythm (400–800 ms typical).
- VAD-heavy systems: If VAD commits reliably, set
stability_timeout_ms higher or use disableStabilityTimer option in code.
- Word-slicing robustness: Settings survive Scribe word revisions (e.g., “Well” → “What”) via word-count deduplication.
API Endpoints
GET /admin/stt-timing
Retrieve current STT timing configuration.
curl -X GET http://localhost:3001/admin/stt-timing \
-H "x-admin-password: admin123"
# Response:
{
"settings": {
"commit_merge_ms": 2500,
"stability_timeout_ms": 3500,
"tts_segment_pause_ms": 600
}
}
POST /admin/stt-timing
Update STT timing settings (partial updates supported).
curl -X POST http://localhost:3001/admin/stt-timing \
-H "x-admin-password: admin123" \
-H "Content-Type: application/json" \
-d {
"commit_merge_ms": 1500,
"stability_timeout_ms": 2500
}
# Response:
{
"settings": {
"commit_merge_ms": 1500,
"stability_timeout_ms": 2500,
"tts_segment_pause_ms": 600
}
}
Socket Events
The frontend receives STT timing via Socket.IO on connection:
socket.on('stt_timing', (data) => {
console.log('TTS segment pause:', data.tts_segment_pause_ms, 'ms');
// Use tts_segment_pause_ms for playback timing between audio chunks
});
Notes
- Settings are persisted to Redis on update and survive server restarts.
commit_merge_ms & stability_timeout_ms control backend translation latency; tts_segment_pause_ms is frontend-only.
- VAD (Voice Activity Detection) commits fire automatically when silence is detected—commit buffer prevents over-fragmentation.
- Stability timer acts as a fallback if VAD doesn't fire (e.g., slow speech or background noise).
- All timers use milliseconds; aim for 1000–4000 ms range for natural conversation feel.
Authentication: All endpoints require the X-Admin-Password header with the value of ADMIN_PASSWORD environment variable (default: admin123).
API Keys
Retrieve status of all configured API keys (elevenlabs, anthropic, deepl, libretranslate).
Update one or more API keys. Only provided keys are updated; omitted keys are unchanged.
Body: {
"elevenlabs": "string",
"anthropic": "string",
"deepl": "string",
"libretranslate": "string"
}
Voice Management
Scan & list all available ElevenLabs voices with name, ID, category, & preview URL.
Get the list of voice IDs allowed for viewer selection (null → all voices allowed).
Set the pool of allowed voice IDs that viewers can select from; broadcasts update to all connected clients.
Body: {
"voiceIds": ["voice_id_1", "voice_id_2", ...]
}
Clone a voice from base64-encoded browser microphone recordings; creates custom voice in ElevenLabs.
Body: {
"name": "string (required)",
"clips": ["base64_audio_blob_1", "base64_audio_blob_2", ...],
"mimeType": "audio/webm (optional)"
}
Clone a voice from a YouTube video by extracting N×30s audio clips using yt-dlp & ffmpeg.
Body: {
"name": "string (required)",
"youtubeUrl": "string (required)",
"clipCount": "number (1–25, default 3)",
"startOffset": "number (ms, default 0)"
}
TTS & STT Settings
Retrieve current TTS (text-to-speech) settings: stability, similarity_boost, style, speed, use_speaker_boost.
Update TTS settings (partial update allowed); changes apply to all new TTS requests.
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: commit_merge_ms, stability_timeout_ms, tts_segment_pause_ms.
Update STT timing controls for VAD commit buffering & stability-based translation triggering.
Body: {
"commit_merge_ms": 2500,
"stability_timeout_ms": 3500,
"tts_segment_pause_ms": 600
}
Languages
Get the currently active language pair [source, target] for live translation.
Set the active language pair; broadcasts update to all connected viewers in real-time.
Body: {
"languages": ["en", "ru"]
}
Get the pool of language codes available for viewers to choose from.
Update the pool of available languages & broadcast to all connected clients.
Body: {
"languages": ["en", "ru", "uk", "es", ...]
}
Translation Provider
Retrieve the active translation provider & list available options: deepl, claude, libretranslate.
Switch the active translation provider (deepl, claude, or libretranslate).
Body: {
"provider": "deepl" | "claude" | "libretranslate"
}
Audio Device
Get the admin-selected audio input device (overrides viewer's local selection).
Set the forced audio input device & broadcast to all viewers; they will use this device instead of their local selection.
Body: {
"deviceId": "string",
"label": "string"
}
Video Call Settings
Retrieve video call STT/TTS settings: stability_ms, commit_merge_ms, translation_provider.
Update video call translation settings (separate from main live-translation config).
Body: {
"stability_ms": 500,
"commit_merge_ms": 50,
"translation_provider": "libretranslate" | "claude" | "deepl"
}
Feature Flags
Retrieve all feature flags merged from YAML config defaults & Redis overrides.
Get the value of a specific feature flag.
Set a feature flag value & broadcast updated flags to all connected clients.
Body: {
"value": true | false
}
Content Generation
Generate a 1–2 sentence biblical sermon excerpt via Claude Haiku in the specified language (English, Russian, or Ukrainian).
Body: {
"apiKey": "string (optional, uses stored key if omitted)",
"language": "ru" | "uk" | "en"
}
Utility
Retrieve the currently configured Anthropic API key (used for sermon generation & translation).
Socket.IO Events
Server → Client Events
| Event |
Payload |
Description |
feature_flags |
Record<string, boolean> |
Merged feature flags from YAML config & Redis overrides sent on connection and after admin updates. |
languages |
{ languages: string[] } |
Current active language pair (2-element array) sent on connection and after admin/viewer change. |
available_languages |
{ languages: string[] } |
Pool of allowed language codes that viewers can select from; sent on connection and after admin update. |
available_voices |
{ voiceIds: string[] } |
Admin-restricted list of ElevenLabs voice IDs available for TTS. |
stt_timing |
{ tts_segment_pause_ms: number } |
Frontend pause duration between TTS audio segments (milliseconds). |
admin_audio_device |
{ deviceId: string; label: string } |
Admin-selected audio input device that overrides viewer’s local selection. |
session_started |
{ source: 'mic' | 'youtube' | 'biblical' } |
Session initialization complete; indicates the audio source type. |
transcript |
{ text: string; isFinal: boolean } |
STT output from ElevenLabs Scribe or biblical simulator; isFinal=true when VAD or stability fires. |
translation |
{ original: string; translated: string; detectedLanguage: string } |
Translated text after processing the final transcript. |
tts_audio |
{ audio: string } |
Base64-encoded MP3 audio buffer of the translated text. |
audio_level |
{ data: number[] } |
Downsampled PCM waveform (64 samples, normalized 0–1) for visualizing mic/stream input. |
stream_ended |
{} |
YouTube audio stream or biblical simulator stream completed. |
session_stopped |
{} |
Session explicitly stopped by client or closed unexpectedly. |
admin_translate_result |
{ original: string; translated: string; detectedLanguage: string; audio: string } |
Result of admin translation test — includes base64-encoded MP3 audio. |
error |
{ message: string } |
Error notification from STT, translation, TTS, or stream processing. |
Client → Server Events
| Event |
Payload |
Description |
set_languages |
{ languages: string[] } |
Viewer selects 2-element language pair from available pool; validated and broadcast to all clients. |
start_session |
{ voiceId?: string; source: 'mic' | 'youtube'; youtubeUrl?: string } |
Begin STT/translation session from microphone or YouTube stream; creates ElevenLabs Scribe session. |
audio_chunk |
{ audio: string } |
Base64-encoded PCM audio chunk from browser microphone; forwarded to Scribe STT. |
stop_session |
{} |
Stop the active session, close Scribe STT, halt YouTube streaming. |
admin_translate_test |
{ text: string; voiceId?: string; sourceLang?: string; targetLang?: string } |
Admin-initiated translation & TTS test; bypasses language-pair restrictions. |
start_biblical_sim |
{ anthropicApiKey: string; language: BiblicalLanguage; voiceId?: string } |
Begin biblical text simulator using Anthropic Claude; generates sentences streamed through translation & TTS. |
stop_biblical_sim |
{} |
Stop the biblical simulator stream. |
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
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 |
Nginx (custom build) |
80 (exposed) |
Serves React build, proxies API/WS to backend |
| backend |
Node.js (custom build) |
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
Shipped
v0.1 – v0.2 — Core Translation Engine
- Real-time STT via ElevenLabs Scribe v2 Realtime
- Multi-provider translation (LibreTranslate, DeepL, Claude)
- TTS voice synthesis with ElevenLabs
- Microphone and YouTube live input
- Admin panel with feature flags, voice management, TTS tuning
- Biblical Transcript Simulator for pipeline testing
- Instant Voice Cloning from recordings and YouTube
Shipped
v0.3 — Audio Mixer & Device Selection
Browser-side audio device scanning with support for professional mixing consoles, virtual audio devices, and audio interfaces.
- Browser-side device enumeration with permission flow
- Virtual device detection (Loopback, BlackHole, VB-Audio, Voicemeeter, OBS)
- Categorized device picker (Microphones vs Mixers / Virtual Devices)
- Admin device override broadcast to all viewers via Socket.io
- Real-time feature flag broadcasting
Shipped
v0.7 — Broadcast Service
The /translate route is now a true broadcast service. Admins start one global translation session from the admin panel and all connected viewers receive the live output simultaneously.
- Single global broadcast session (one-to-many)
- Admin "Broadcast Control" panel — Start/Stop with source + voice selection
- Microphone and YouTube source both supported for broadcast
- All translation output (transcript, translated text, TTS audio)
io.emit’d to every viewer
- Viewer shows Waiting for broadcast to start… status when off air
- "On Air" / "Off Air" status pill visible to viewers in real-time
- Broadcast ownership tracked by admin socket ID; auto-stops on admin disconnect
- Biblical Transcript Simulator also broadcasts to all viewers
Up Next
v0.4 — Direct Audio Interface Feed
Accept audio directly from professional mixing consoles and audio interfaces — bypass browser mic capture entirely for broadcast-quality input.
- Direct audio interface input (ASIO / Core Audio / ALSA)
- Multi-channel mixer feed support
- Low-latency audio routing (sub-100ms)
- Hardware device auto-discovery and selection
- Professional broadcast integration (NDI, Dante)
Shipped
v0.5 — Video Call Translation
WebRTC peer-to-peer video calls with real-time bidirectional translation. Two people speak different languages and hear each other translated via TTS.
- Built-in WebRTC video call with room codes
- Full-duplex translation (each person hears the other translated)
- Per-participant STT pipeline with independent Scribe sessions
- Video grid UI with local PiP and remote full-screen
- Mic/video mute controls, hang up, auto-cleanup on disconnect
- Feature-flagged behind
video_translation
Shipped
v0.6 — Auth, Mobile & Voice Cloning in /video
- User-facing login page (
/) with JWT cookie sessions (30-day sticky, HttpOnly)
- All app routes protected — redirect to login if unauthenticated
- Live translator moved to
/translate
- Mobile-responsive UI across Translator, Admin, and Video Call views
- FaceTime-style full-screen in-call layout on mobile with safe-area insets
- “Clone Voice” button in
/video lobby, gated by video_voice_cloning feature flag
- Voice cloning modal with mic recording or YouTube URL, admin-password gated
Planned
Future
- Additional language pairs beyond EN/RU/UK
- Speaker diarization (multi-speaker detection)
- Translation memory and glossary support
- Webhooks and API for third-party integrations
- Multi-tenant deployment with user accounts