# nazdridoy/kokoro-tts architecture

> Architecture diagram of the GitHub repository nazdridoy/kokoro-tts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nazdridoy/kokoro-tts
- Repository: https://github.com/nazdridoy/kokoro-tts

## Overview

##### Component Relationships

- Input → Text Processing → Model Processing → Audio Output
- Parallel paths for different input types
- How the voice blending system interfaces with the core model

##### Specific Components

Input Processing:
**┌─────────────────┐**
- Input Layer   │
- ┤
- EPUB Parser   │
- TXT Parser    │
- PDF Parser    │
- (Future)       │
- ┘

Core Processing:
**┌──────────────────────┐**
- Processing Layer   │
- ┤
- Kokoro ONNX Model │
- Voice Blender     │
- Language Selector │
- Speed Controller  │
- ┘

Output Processing:
**┌─────────────────────┐**
- Output Layer      │
- ┤
- WAV Generator    │
- MP3 Generator    │
- Stream Handler   │
- Chapter Splitter │
- ┘

##### Key Elements to Highlight

- Blue: Input components
- Green: Core processing
- Orange: Output components
- Gray: Future/planned features

- Double lines: API boundaries

##### Additional Details

Supporting systems:
- Configuration management
- Debug logging system
- Model file management
- Voice profile storage

##### Technical Stack Indicators

Dependencies:
- kokoro-onnx[gpu]
- soundfile/sounddevice
- ebooklib
- beautifulsoup4

##### Processing Flow Details

Main processing pipeline:
**Input → Text Chunking → Language Processing → Voice Selection →**
**Model Processing → Audio Generation → Output Handling**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef input fill:#a8d1f0,stroke:#2c89c4
    classDef core fill:#b7e3b7,stroke:#3c993c
    classDef output fill:#ffd4aa,stroke:#ff9933
    classDef future fill:#e0e0e0,stroke:#888888,stroke-dasharray: 5 5
    classDef config fill:#d4d4d4,stroke:#666666

    %% Input Layer
    subgraph InputLayer["Input Layer"]
        EPUBParser["EPUB Parser"]:::input
        TXTParser["TXT Parser"]:::input
        PDFParser["PDF Parser"]:::future
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        KokoroModel["Kokoro ONNX Model"]:::core
        VoiceBlender["Voice Blender"]:::core
        LangSelector["Language Selector"]:::core
        SpeedControl["Speed Controller"]:::core
        TextChunking["Text Chunking"]:::core
    end

    %% Output Layer
    subgraph OutputLayer["Output Layer"]
        WAVGen["WAV Generator"]:::output
        MP3Gen["MP3 Generator"]:::output
        StreamHandler["Stream Handler"]:::output
        ChapterSplitter["Chapter Splitter"]:::output
    end

    %% Supporting Systems
    subgraph Support["Supporting Systems"]
        Config["Configuration"]:::config
        DebugLog["Debug Logger"]:::config
        ModelMgmt["Model Management"]:::config
        VoiceProfiles["Voice Profiles"]:::config
    end

    %% Relationships
    EPUBParser --> TextChunking
    TXTParser --> TextChunking
    PDFParser -.-> TextChunking
    
    TextChunking --> LangSelector
    LangSelector --> VoiceBlender
    VoiceBlender --> KokoroModel
    SpeedControl --> KokoroModel
    
    KokoroModel --> WAVGen
    KokoroModel --> MP3Gen
    KokoroModel --> StreamHandler
    
    WAVGen --> ChapterSplitter
    MP3Gen --> ChapterSplitter
    
    Config --> KokoroModel
    Config --> VoiceBlender
    ModelMgmt --> KokoroModel
    VoiceProfiles --> VoiceBlender

    %% Click Events
    click Config "https://github.com/nazdridoy/kokoro-tts/blob/main/pyproject.toml"

    %% Legend
    subgraph Legend["Legend"]
        L1["Current Component"]:::core
        L2["Future Component"]:::future
        L3["Input Processing"]:::input
        L4["Output Processing"]:::output
        L5["Configuration"]:::config
    end
```
