How kedreamix/linly-talker-stream works
1. Overall shape
Linly-Talker-Stream is a split frontend/backend system for real-time digital-human conversation. The browser client handles user interaction and playback, while the Python backend orchestrates ASR, LLM, TTS, avatar rendering, and WebRTC streaming.
2. Frontend boundary
The web/ app is a Vue 3 + Vite client. Its main responsibilities are browser media capture, speech-recognition UI, WebRTC session setup, settings/config selection, and video/audio playback. The frontend is the user-facing edge of the system, not where model inference happens.
3. Backend boundary
The backend lives under src/server/ and is the central coordination layer. It exposes the HTTP/WebRTC API surface, keeps runtime state, routes requests to the multimodal pipeline, and returns synthesized audio/video or streaming session negotiation data.
4. Realtime transport
WebRTC is the key transport boundary. POST /offer performs SDP negotiation, and the backend uses aiortc/aiohttp-style server plumbing to stream generated media back to the browser with low latency. This is the main mechanism that turns the system from request/response into full-duplex interaction.
5. Conversation pipeline
The core data flow is: browser microphone input → ASR → text generation via LLM → speech synthesis via TTS → avatar driving/rendering → streamed audio/video back to the browser. The repository explicitly supports both browser-side speech recognition and server-side ASR paths, which affects where the first transcription boundary sits.
6. ASR subsystem
src/asr/ contains pluggable speech-to-text engines. The concrete engines shown are Whisper and FunASR, selected through a factory layer. This subsystem is independent from the avatar engines and can be swapped based on deployment or language requirements.
7. LLM subsystem
src/llm/ is a thin adapter layer around text-generation backends. The repo includes an OpenAI-style engine wrapper, and the README indicates DashScope/Qwen-plus as the default service. The LLM is treated as a service boundary, not a local model bundle.
8. TTS subsystem
src/tts/ provides multiple synthesis backends: Azure, Edge, CosyVoice, Fish, XTTS, Tencent, Doubao, SoVITS, and others. This makes speech generation another pluggable boundary, with providers ranging from cloud APIs to local models.
9. Avatar engines
src/avatars/ is the largest subsystem and contains multiple mutually replaceable avatar pipelines: wav2lip, musetalk, ernerf, talkinggaussian, plus additional lightweight variants. Each avatar package owns its own audio stream handler, model logic, preprocessing, and asset dependencies. The backend chooses one based on model.type in config.
10. GPU-heavy submodules
The 3D/avatar-rendering paths include custom CUDA and rasterization code. talkinggaussian pulls in diff-gaussian-rasterization, simple-knn, and gridencoder; ernerf also includes CUDA-based encoders and raymarching. These are separate build/install boundaries and are the most infrastructure-sensitive part of the repo.
11. Preprocessing and asset preparation
Several avatar packages include data-prep pipelines for face detection, face parsing, tracking, audio feature extraction, and avatar generation. These are offline or startup-time preparation steps that feed the runtime avatar engines with weights, landmarks, meshes, or extracted features.
12. Configuration and startup
config/*.yaml drives the whole runtime: server port, SSL, ASR mode, avatar type, TTS engine, and LLM settings. src/config/ loads and validates these settings, while scripts/ handles environment setup, module-specific installs, SSL certificate creation, and starting backend/frontend together.
13. External dependencies and deployment constraints
The system depends on browser media APIs, HTTPS for microphone access in remote use, and external model/service credentials such as DASHSCOPE_API_KEY. Because of the modular avatar packages and GPU extensions, installation is intentionally split so deployments only pull in the selected avatar stack.
14. Useful diagram boundaries
For an architecture diagram, the main boxes should be: browser UI, WebRTC transport, backend orchestration, ASR/LLM/TTS services, avatar engine variants, and optional GPU/CUDA submodules. The clearest arrows are media/input flow from browser to backend, text flow through ASR/LLM/TTS, and synthesized media flow back over WebRTC.
Main entry points: routes API Routes · factory.py Avatar Factory · loader.py Config Loader · web Web App
Components 24
Browser UI
Vue client for interaction, media capture, and playback.
- Web App · Browser-side interface for interaction, settings, recording, and playback.
web - WebRTC Hook · Browser composable for session setup and realtime transport.
web/src/composables/useWebRTC.js - Speech Hook · Browser speech-recognition integration for user input.
web/src/composables/useSpeechRecognition.js - Video Player · Client-side audio/video rendering surface.
web/src/components/VideoPlayer.vue
Python Backend
Server-side orchestration, routing, and runtime state.
- Server App · Backend application entry that assembles API routes and runtime services.
src/server/app.py - API Routes · HTTP surface for chat, audio, video, health, and SDP negotiation.
src/server/routes - Runtime State · Shared backend state for active conversations and stream coordination.
src/server/state.py - WebRTC Utils · Helpers for session negotiation and media streaming plumbing.
src/utils/webrtc.py
Speech Services
Pluggable ASR, LLM, and TTS layers.
- ASR Factory · Chooses the active speech-to-text backend.
src/asr/factory.py - ASR Engines · Whisper and FunASR implementations behind a common interface.
src/asr/engines - LLM Service · Text-generation service boundary used by the conversation loop.
src/llm/service.py - OpenAI Adapter · OpenAI-style LLM engine wrapper, including service-hosted models.
src/llm/engines/openai.py - TTS Factory · Chooses the active text-to-speech backend.
src/tts/factory.py - TTS Engines · Pluggable synthesis backends such as Azure, Edge, CosyVoice, XTTS, and others.
src/tts/engines
Avatar Engines
Replaceable avatar pipelines and renderers.
- Avatar Factory · Selects the avatar pipeline from configuration.
src/avatars/factory.py - Wav2Lip · Lip-sync avatar path for audio-driven facial animation.
src/avatars/wav2lip - MuseTalk · Talking-head avatar path with its own preprocessing and runtime handlers.
src/avatars/musetalk - ER-NeRF · Neural rendering avatar path with preprocessing and GPU-heavy components.
src/avatars/ernerf - Talking Gaussian · Gaussian-splatting avatar path for realtime rendering.
src/avatars/talkinggaussian - Ultralight · Lightweight avatar path for faster or simpler deployments.
src/avatars/ultralight
GPU Submodules
CUDA and rasterization extensions used by 3D avatar paths.
- CUDA Extensions · Custom GPU submodules for Gaussian rendering and neural encoding.
src/avatars/talkinggaussian/submodules
Startup & Config
Config loading and launch scripts that wire the system together.
- Config Loader · Loads and validates runtime configuration.
src/config/loader.py - Config Files · YAML settings for server, ASR, avatar, TTS, and LLM selection.
config/config.yaml - Launch Scripts · Shell scripts for setup, SSL creation, and starting backend/frontend.
scripts
Connections 30
- Web App → WebRTC Hook: setup session · The UI opens realtime media sessions through the WebRTC composable.
- Web App → Speech Hook: capture speech · The UI exposes browser speech-recognition input.
- Web App → Video Player: play media · The UI renders streamed audio/video for the conversation.
- WebRTC Hook → API Routes: offer/answer · Browser negotiation reaches the backend WebRTC route.
- Server App → API Routes: mount routes · The backend app assembles the HTTP and WebRTC endpoints.
- Server App → Runtime State: share state · The backend keeps conversation and stream state in a shared store.
- API Routes → WebRTC Utils: transport · Routes delegate session and media handling to transport helpers.
- API Routes → ASR Factory: transcribe · Incoming audio or text is handed to the ASR selection layer.
- API Routes → LLM Service: generate reply · Chat requests are routed to the LLM service boundary.
- API Routes → TTS Factory: synthesize voice · Reply text is forwarded to speech synthesis.
- API Routes → Avatar Factory: drive avatar · Synthesized speech is handed to the avatar selector.
- ASR Factory → ASR Engines: whisper/funasr · The factory chooses among concrete ASR engines.
- LLM Service → OpenAI Adapter: model adapter · The service wraps an OpenAI-style generation backend.
- TTS Factory → TTS Engines: provider pick · The factory selects one of the pluggable TTS providers.
- Avatar Factory → Wav2Lip: select · One configurable avatar path is Wav2Lip.
- Avatar Factory → MuseTalk: select · One configurable avatar path is MuseTalk.
- Avatar Factory → ER-NeRF: select · One configurable avatar path is ER-NeRF.
- Avatar Factory → Talking Gaussian: select · One configurable avatar path is Talking Gaussian.
- Avatar Factory → Ultralight: select · One configurable avatar path is the lightweight avatar stack.
- ER-NeRF → CUDA Extensions: uses · ER-NeRF depends on custom GPU encoders and rasterization pieces.
- Talking Gaussian → CUDA Extensions: uses · Talking Gaussian depends on CUDA and rasterization submodules.
- Config Files → Config Loader: load · YAML files are parsed into validated runtime settings.
- Config Loader → Server App: configure runtime · Loaded settings determine server behavior and model selection.
- Config Loader → Avatar Factory: model.type · Configuration picks the active avatar engine.
- Config Loader → ASR Factory: asr mode · Configuration picks the active ASR backend.
- Config Loader → TTS Factory: tts engine · Configuration picks the active TTS backend.
- Config Loader → LLM Service: llm config · Configuration supplies the conversation model settings.
- Launch Scripts → Config Files: seed settings · Setup scripts populate and use configuration files.
- Launch Scripts → Server App: start backend · Launch scripts boot the Python server.
- Launch Scripts → Web App: start frontend · Launch scripts boot the browser client.