# kedreamix/linly-talker architecture

> Architecture diagram of the GitHub repository kedreamix/linly-talker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kedreamix/linly-talker
- Repository: https://github.com/kedreamix/linly-talker

## Overview

##### Project type and purpose
- Linly-Talker is a full-stack, modular digital human dialogue system.
- It provides a Gradio-based WebUI frontend and FastAPI-style invocation for orchestrating:
- ASR (speech-to-text)
- LLM (dialogue)
- TTS (text-to-speech & voice-cloning)
- THG (talk-head generation: lip-sync, avatar animation, NeRF)
- Users supply images, voice or text; the system responds with synchronized speech and animated digital humans.

##### File structure
- Top-level orchestrator scripts:
- webui.py – unified Gradio UI hosting all modules
- app*.py – legacy or specialized entrypoints (app_img.py, app_talk.py, app_musetalk.py…)
- api/ – wrappers for exposing module functionality over FastAPI
- ASR/, TTS/, VITS/ (voice clone), GPT_SoVITS/, CosyVoice/ – each implements a speech module
- LLM/ – adapters for multiple large‐language models (ChatGPT, Qwen, Gemini, etc.)
- TFG/ (THG) and MuseTalk/ – deep models for head generation (SadTalker, Wav2Lip, ER-NeRF, MuseTalk)
- configs.py – central configuration (ports, model paths, SSL certs)
- checkpoints/, GPT_SoVITS/pretrained_models/, MuseTalk/models/, Qwen/, Whisper/, FunASR/ – pre-downloaded weights
- scripts/ – installation/download helpers
- src/ – lower-level research code (face3d, facerender, audio2pose, etc.) supporting THG pipeline

##### README for insights
- The README describes a multimodal pipeline (HOI_en.png):
User → ASR → LLM → TTS → THG → Output
- It lists supported submodules and how to configure them

- WebUI / API Layer
- Core Orchestrator
- ASR Module
- LLM Module
- TTS Module (edge, paddle, CosyVoice, GPT-SoVITS etc.)
- Voice-Clone Module (GPT-SoVITS, XTTS, CosyVoice)
- THG Module (SadTalker, Wav2Lip, Wav2Lipv2, ER-NeRF, MuseTalk)
- Models Storage (checkpoints/, pretrained_models/)
- External Services (openai.com, HuggingFace, Edge TTS service, ModelScope)
1. User → WebUI (image, microphone, text input)
2. WebUI → Orchestrator (via function calls or FastAPI endpoints)
3. Orchestrator → ASR Module → transcribed text
4. Orchestrator + context → LLM Module → response text
5. Response text → TTS Module → speech audio
6. Optionally: speech + image → Voice-Clone Module → cloned voice
7. Image + audio → THG Module → talking avatar video
8. Media back to WebUI for display/playback
9. Any module may read weights from Models Storage
10. Some modules call external APIs (LLM, Edge TTS)
c. Architectural patterns / principles:
- Modular plugin architecture: each capability is a self-contained Python package
- “Orchestrator” implements a pipeline pattern
- Separation of concerns: UI, API, orchestration, and individual AI modules are decoupled
- Config-driven: configs.py and YAML/JSON under configs/ govern model selection & hyperparameters
d. Technologies & frameworks:
- Gradio (frontend)
- FastAPI (optional API layer)
- PyTorch, ONNX (models)
- HuggingFace Transformers, ModelScope
- CosyVoice, PaddleSpeech, edge-tts libraries
- OpenAI Whisper, Alibaba FunASR
- RVC-Based GPT-SoVITS, Coqui XTTS
- SadTalker, Wav2Lip, ER-NeRF, MuseTalk for video generation
- Docker / conda for environment, scripts/install.sh

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User"]:::external
    subgraph "UI / API Layer"
        WebUI["WebUI (Gradio)"]:::frontend
        API["FastAPI Endpoints"]:::frontend
        Entrypoints["App Entrypoints"]:::frontend
    end
    subgraph "Core"
        Orchestrator["Core Orchestrator"]:::orchestrator
    end
    subgraph "Modules"
        ASR["ASR Module<br/>(Whisper, FunASR, OmniSense)"]:::module
        LLM["LLM Module<br/>(ChatGPT, Qwen, Gemini, etc.)"]:::module
        TTS["TTS Module<br/>(EdgeTTS, PaddleTTS, XTTS)"]:::module
        VoiceClone["Voice-Clone Module<br/>(GPT-SoVITS, CosyVoice, XTTS)"]:::module
        THG["THG Module<br/>(SadTalker, Wav2Lip, ER-NeRF, MuseTalk)"]:::module
    end
    subgraph "Resources"
        Storage["Models Storage"]:::storage
        Config["Configuration<br/>(configs.py, src/config/)"]:::storage
        Scripts["Install & Download Scripts"]:::storage
    end
    subgraph "External Services"
        ExtLLM["LLM API<br/>(OpenAI, HuggingFace)"]:::external
        ExtTTS["Edge TTS Service"]:::external
    end

    User -->|"image/audio/text"| WebUI
    WebUI -->|calls| Orchestrator
    API -->|calls| Orchestrator
    Entrypoints -->|invoke| Orchestrator

    Orchestrator -->|"audio → text"| ASR
    Orchestrator -->|"text → text"| LLM
    Orchestrator -->|"text → audio"| TTS
    Orchestrator -->|"audio → cloned audio"| VoiceClone
    Orchestrator -->|"image + audio → video"| THG

    ASR -->|loads models| Storage
    LLM -->|loads models| Storage
    TTS -->|loads models| Storage
    VoiceClone -->|loads models| Storage
    THG -->|loads models| Storage

    LLM -->|API calls| ExtLLM
    TTS -->|API calls| ExtTTS

    Orchestrator -->|media output| WebUI

    click WebUI "https://github.com/kedreamix/linly-talker/blob/main/webui.py"
    click API "https://github.com/kedreamix/linly-talker/tree/main/api/"
    click Entrypoints "https://github.com/kedreamix/linly-talker/blob/main/app.py"
    click Orchestrator "https://github.com/kedreamix/linly-talker/blob/main/app.py"
    click ASR "https://github.com/kedreamix/linly-talker/tree/main/ASR/"
    click LLM "https://github.com/kedreamix/linly-talker/tree/main/LLM/"
    click TTS "https://github.com/kedreamix/linly-talker/tree/main/TTS/"
    click VoiceClone "https://github.com/kedreamix/linly-talker/tree/main/VITS/"
    click THG "https://github.com/kedreamix/linly-talker/tree/main/TFG/"
    click Storage "https://github.com/kedreamix/linly-talker/tree/main/checkpoints/"
    click Config "https://github.com/kedreamix/linly-talker/blob/main/configs.py"
    click Scripts "https://github.com/kedreamix/linly-talker/tree/main/scripts/"

    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#1B4F72,stroke-width:1px
    classDef orchestrator fill:#D5F5E3,stroke:#27AE60,color:#145A32,stroke-width:1px
    classDef module fill:#FCF3CF,stroke:#F1C40F,color:#7D6608,stroke-width:1px
    classDef storage fill:#E5E8E8,stroke:#7F8C8D,color:#1C2833,stroke-width:1px
    classDef external fill:#FADBD8,stroke:#E74C3C,color:#641E16,stroke-width:1px
```
