// docs / websocket-obs
WebSocket & OBS
LiveAudio runs a local WebSocket server that broadcasts subtitle JSON in real time to the built-in OBS /overlay (7 live themes + anti-burst reconnection) or any HTML/WebSocket client on localhost.
Server details
| Parameter | Value |
|---|---|
| Protocol | WebSocket (ws://) |
| Host | 127.0.0.1 (localhost only) |
| Port | 8765 by default, configurable via ws_port. If it is busy, the server tries the next ports up to ws_port + 9 (8765–8774 by default). |
| Effective port | Announced in the first frame of every connection (hello) and shown in the app as the WS: <port> pill. |
| Overlay URL | http://127.0.0.1:<port>/overlay — the OBS Browser Source URL. ws://127.0.0.1:<port> is the WebSocket endpoint, not what you paste into OBS. |
| Format | JSON |
| Auth | None — loopback-only listener plus an Origin allowlist (see Security) |
JSON payload schema
{
"id": "utt_42",
"text": "Hello everyone, welcome to the stream",
"style": "default",
"created_at": 1760000000.0,
"processed_at": 1760000001.3,
"queue_delay": 0.2,
"total_delay": 1.3,
"latency": 1.1,
"is_replay": false,
"catchup_interval_sec": 0.0
}| Field | Type | Description |
|---|---|---|
id | string | Opaque per-session phrase identifier, such as utt_42. It restarts on each run and is not monotonic. |
text | string | Transcribed text, after blacklist filtering. |
style | string | Visual style: default, karaoke, neon, minimal, bold, rgb, typewriter. |
created_at | number | Timestamp when the audio segment was created. |
processed_at | number | Timestamp when transcription completed. |
queue_delay | number | Seconds the audio waited before entering the ASR engine. |
total_delay | number | Total delay from audio capture to a ready subtitle. |
latency | number | Seconds the ASR engine (Parakeet-TDT or Whisper) spent transcribing the segment. |
is_replay | boolean | Whether this is a backlog / catch-up subtitle. |
catchup_interval_sec | number | Recommended pacing between backlog items in auto mode. |
The built-in OBS overlay consumes text, style, is_replay, catchup_interval_sec, theme frames and optional subtitle_partial frames. The remaining fields are metadata for diagnostics — useful if you build your own client, ignorable if you do not. Frames that carry a type field (hello, theme, subtitle_partial) are not captions.
Subtitle styles
The style field selects one of seven built-in looks, switchable from the Style tab, which also holds presets and a live preview (the Subtitles tab holds the display mode: adaptive, single or ribbon):
| Style | Look |
|---|---|
default | White text on a semi-transparent black background, soft fade in/out. |
karaoke | Words appear staggered with a popIn animation; bright yellow with a black outline. |
neon | Cyan glow, uppercase, wide letter-spacing. |
minimal | No background, subtle fade — for streams with their own design. |
bold | High-contrast thick text, fast animation, strong on-screen presence. |
rgb | Each word takes a different rainbow color. |
typewriter | Words type in one at a time with a blinking cursor; monospaced. |
OBS backlog policy
The backlog policy controls only what shows live in OBS. Everything valid is always saved to disk regardless of policy.
| Mode | Config value | Behavior |
|---|---|---|
| Auto | auto | Sends fresh subtitles plus a short, paced backlog. Drops anything past the max delay. |
| Live only | live_only | Saves everything; shows only what is within subtitle_max_live_delay_sec. |
| Send all | send_all | Sends everything to OBS even when it arrives late. |
Security
- Loopback only — the server binds
127.0.0.1and drops peers that are not loopback. - Origin rules — no
Originheader (native apps, scripts) is accepted; severalOriginheaders get HTTP403.http://absolute(OBS Browser Source),tauri.localhost, and loopback origins on the server's bound port (the/overlaypage) or on an allowlisted port are accepted; anything else gets403. - Allowlist — add the port of any other local browser tool in Advanced > Allowed local connections (default
[1420]). The card also lists recent blocked attempts. - Limits — at most 64 simultaneous connections, inbound messages up to 64 KiB, and a 5 s handshake timeout.
- No authentication — any local process that sends no
Origincan read subtitles. - Broadcast — multiple clients receive the same messages simultaneously.
OBS Browser Source setup
- In OBS, Sources → + → Browser.
- Start the system, then copy the overlay URL from LiveAudio (Copy URL; the base form is
http://127.0.0.1:8765/overlay). Leave Local file unchecked in OBS and paste the URL. Set size 1920×1080. - Set FPS to
30or60. Keep the source at the full canvas: the overlay positions the captions itself. - Disable "Shut down source when not visible" and "Refresh browser when scene becomes active" — both can drop the WebSocket connection.
- While the system is running, the copied overlay URL includes the active WebSocket port. The server starts at
ws_port(default8765) and may use an alternative up tows_port + 9; copy the URL again if the port changes.
Connection behavior
- Anti-burst reconnect. The bundled
/overlaypage retries with exponential backoff from 1 s up to 8 s, rescans portsws_portthroughws_port + 9, and uses anti-burst reconnection so captions stay clean if OBS reconnects mid-stream. A custom client needs its own retry logic. - Broadcast. Every connected client receives every message. Multiple clients (OBS plus a debug browser tab) all see the same stream, and a slow client does not block the others.
- Slow clients. Each client has a 64-frame outgoing queue and a 10-frame retry queue. When the retry queue is full the oldest frame is dropped; the client is not disconnected.
Build your own client
Any localhost WebSocket client can subscribe to the same broadcast OBS reads. A minimal browser client. Serve it from a local HTTP server and add that server's port to Allowed local connections: a page opened from file:// sends Origin: null and is rejected with 403. It skips frames that have a type field and renders only caption frames:
<!-- serve from a local http server, e.g. python -m http.server 5500
(file:// sends Origin: null and gets 403), then allow port 5500 in
Advanced > Allowed local connections -->
<div id="caption"></div>
<script>
const PORT = 8765; // base port; the effective port is announced in the hello frame
let ws;
function connect() {
ws = new WebSocket("ws://127.0.0.1:" + PORT);
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if ("type" in msg) return; // hello, theme, subtitle_partial: not a caption
document.getElementById("caption").textContent = msg.text;
};
// retry after 3 s if the connection drops (this sample's own choice)
ws.onclose = () => setTimeout(connect, 3000);
}
connect();
</script>Or a minimal Python client, to print every caption as it arrives (requires the websockets package; non-browser clients send no Origin, so no allowlist entry is needed):
import asyncio, json, websockets
async def main():
# ping_interval=None: the server answers pings only after its replay burst
async with websockets.connect("ws://127.0.0.1:8765", ping_interval=None) as ws:
async for frame in ws:
msg = json.loads(frame)
if "type" in msg: # hello, theme, subtitle_partial...: not a caption
continue
print(msg["text"])
asyncio.run(main())Debug signals
These signals tell you where a stalled overlay is stuck:
| Signal | Meaning |
|---|---|
WS: <port> pill in the app | The WebSocket server is running on that port, with the number of connected clients. Use this port if you build your own client. WS: off means the service is stopped. |
| Browser devtools (F12) on the overlay page | Network → WS shows the frames the overlay receives; the Console shows its errors. |
Error parseando WebSocket (console) | A non-JSON message reached the overlay — the payload was not a valid frame. |
HTTP 403 on the handshake | The page's Origin is not allowed. Add its port in Allowed local connections; check Recent blocked attempts. |