StreamPlayer

TTS audio streaming proxy — Redis Pub/Sub to WebSocket

Running

How It Works

1.Connect via WebSocket to /ws-player with auth token and chat ID
2.Server subscribes to Redis Pub/Sub channel tts:stream:{chatId}
3.When TTS audio is generated, chunks are forwarded as binary WebSocket messages
4.Control frames (tts_start, tts_end, tts_error) sent as JSON text messages

WebSocket Endpoint

GET /ws-player?auth=<token>&chatId=<id>
authJWT token (required)
chatIdChat identifier (required) — alphanumeric, hyphens, underscores, max 128 chars

Server → Client Messages

TypeFormatDescription
tts_startJSON textTTS generation started: { type, messageId, format }
(binary)BinaryMP3 audio chunk
tts_endJSON textTTS generation complete: { type, messageId }
tts_errorJSON textTTS generation failed: { type, messageId, error }

Configuration

VariableDefaultDescription
REDIS_URLredis://redis:6379Redis server for Pub/Sub subscription
IDLE_TIMEOUT_MS300000WebSocket idle timeout (5 minutes)