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
| Type | Format | Description |
| tts_start | JSON text | TTS generation started: { type, messageId, format } |
| (binary) | Binary | MP3 audio chunk |
| tts_end | JSON text | TTS generation complete: { type, messageId } |
| tts_error | JSON text | TTS generation failed: { type, messageId, error } |
Configuration
| Variable | Default | Description |
| REDIS_URL | redis://redis:6379 | Redis server for Pub/Sub subscription |
| IDLE_TIMEOUT_MS | 300000 | WebSocket idle timeout (5 minutes) |