How quentinfuxa/whisperlivekit works
Main Components
• Client Side (Browser Interface):
• Built-in web UI served through a simple HTML page (found under whisperlivekit/web/live_transcription.html) using MediaRecorder for capturing audio.
• Sends audio chunks (in webm/opus format) over WebSocket.
• Server Side (FastAPI Application):
• API entry point (e.g., whisper_fastapi_online_server.py and FastAPI routes in your example code).
• WebSocket endpoint ("/asr") that handles incoming audio from clients.
• HTTP endpoints for serving the web UI.
• Audio Processing & Transcription Modules:
• AudioProcessor (handles decoding, buffering via FFmpeg integration).
• Whisper streaming logic found in whisperlivekit/whisper_streaming_custom modules for ASR.
• Basic server and core coordination in whisperlivekit/basic_server.py and whisperlivekit/core.py.
• Speaker Diarization:
• Dedicated diarization module in whisperlivekit/diarization (using Diart and potentially pyannote models).
• Processes audio streams for real-time speaker identification.
• External Dependencies & Services:
• FFmpeg (for live decoding of audio chunks).
• External model delivery (via dynamic downloading if not cached locally).
• Optional third-party libraries like torch, diart, and pyannote.audio for advanced features.
Relationships & Data Flow
• The Browser (client) captures and sends audio data via WebSocket to the FastAPI backend.
• The FastAPI server receives audio and passes it to the AudioProcessor.
• The AudioProcessor invokes the streaming ASR backend (and optionally the diarization backend) for real-time transcription.
• Processed transcription data is sent back to the client through the WebSocket connection.
• Configuration and inter-module communication (e.g., buffering management and confidence validation) exist between the audio modules and the main server.
Architectural Patterns & Design Principles
• Separation of concerns is evident by distinguishing between:
• Client-side UI (responsible for capturing audio and displaying results)
• Server-side API & business logic (using FastAPI for WebSocket management and routing)
• Audio processing and ASR logic (modularized in separate Python modules)
• Modular design that allows plugging in different Whisper backends and optional diarization.
• Real-time processing with asynchronous event-driven design (e.g., async functions and WebSocket communication).
Relevant Technologies, Frameworks, or Libraries
• FastAPI and WebSocket support for server/client communication.
• FFmpeg for runtime audio decoding.
• Various Whisper ASR backends (faster-whisper, whisper_timestamped, mlx-whisper, or openai-api) for transcription.
• Diart (and pyannote.audio) for real-time speaker diarization.
• Python libraries for async processing, dependency injection, and potentially configuration parsing.
• Each major component should have a clear label:
• "Browser / MediaRecorder (Client)"
• "FastAPI Server (HTTP & WebSocket Endpoints)"
• "AudioProcessor Module (FFmpeg Decoding & Buffering)"
• "Whisper ASR Backend (Streaming Transcription)"
• "Speaker Diarization Module (Diart/pyannote Integration)"
• "Configuration & Optional Integrations (VAC, Model Management)"
• Audio capture flow: Browser → WebSocket → FastAPI → AudioProcessor.
• Transcription flow: AudioProcessor → Whisper ASR backend → (optional: Diarization module) → WebSocket → Browser.
• Annotations where necessary such as “Decoding via FFmpeg”, “Real-time processing with async”, or “Model backend lookup”.
Extra Detail
• Loosely coupled architecture that allows swapping out the ASR backend and enabling/disabling diarization as needed.