# jarodmica/audiobook_maker architecture

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

- Interactive diagram: https://gitdiagram.com/jarodmica/audiobook_maker
- Repository: https://github.com/jarodmica/audiobook_maker

## Overview

##### Project Type & Purpose
- This is a full-stack desktop application designed for Windows (with potential cross-platform UI via PySide6) that leverages multiple open-source deep learning text-to-speech (TTS) and speech-to-speech (S2S) engines to create high-quality audiobooks.
- Its modular design lets you swap in different engines (TortoiseTTS, F5-TTS, StyleTTS, RVC) without hardcoding engine specifics, making the system highly extensible.

##### File Structure
- Notice key top-level directories:
- The “src” folder contains the MVC components:
▪ view.py (GUI interface using PySide6),
▪ controller.py (the application logic/brain),
▪ model.py (handles core functionality and data flow).
- The “engines” directory holds the implementations for each engine category (TTS or S2S) with subdirectories for models, tokenizers, vocoders, etc.
- “modules” encapsulates different API wrappers for TTS engines (e.g., Tortoise, StyleTTS, F5-TTS) to neatly package external integrations.
- “configs” provides JSON and YAML files for engine-specific configurations.
- Other helper directories include “assets” (for styling and images), “voices”, “models”, and directories to manage input texts.

##### Key Components & Their Relationships
a. Core MVC Structure:
- View (GUI): Handles user interactions and dynamically builds widgets based on the configuration and available engines.
- Controller: Interprets the user’s actions, triggers engine-specific functions, and manages workflow (triggering TTS generation, handling regenerations, multi-speaker setup, etc.).
- Model: Contains the business logic and ties together engine outputs, error logging (e.g., returning audio paths), and internal data management.
b. Engine Integration:
- Each engine module connects back to the model (via engine handler functions in src/tts_engines.py and src/s2s_engines.py) that dynamically determine which engine to activate based on configuration files in “configs”.
c. External Dependencies & Deployment:
- Dependencies include CUDA (with a version-verified torch installation) and other libraries like ffmpeg.
- Build scripts such as .bat files (up.bat, finish_styletts_install.bat, update_package.bat) support deployment and installation on Windows systems.

##### Architectural Patterns and Design Principles
- Modularity: The design deliberately separates engine-specific logic from the core functionality, simply returning an audio path to the model. This is vital for maintaining and extending the system.
- MVC Pattern: Clear segregation between the GUI (view), business logic (controller), and core processing (model) helps manage complexity as the system grows.
- Dynamic Component Integration: New engines can be added simply by providing new configuration files, making the system plugin-friendly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% MVC Layer
    subgraph "MVC Layer"
        GUI["GUI (View)"]:::gui
        Controller["Controller"]:::controller
        Model["Model"]:::model
        GUI -->|"sendsCommands"| Controller
        Controller -->|"invokesLogic"| Model
    end

    %% Configuration Management
    subgraph "Configuration"
        Config["Configs (tts_config.json, s2s_config.json, settings.yaml)"]:::config
    end
    Config -->|"providesSettings"| Model

    %% Engine Handlers
    subgraph "Engine Handlers"
        TTSHandler["TTS Engine Handler"]:::handler
        S2SHandler["S2S Engine Handler"]:::handler
    end
    Model -->|"calls"| TTSHandler
    Model -->|"calls"| S2SHandler

    %% TTS Engines
    subgraph "TTS Engines"
        Tortoise["TTS Engine: TortoiseTTS"]:::tts
        F5["TTS Engine: F5-TTS"]:::tts
        Style["TTS Engine: StyleTTS"]:::tts
    end
    TTSHandler -->|"activates"| Tortoise
    TTSHandler -->|"activates"| F5
    TTSHandler -->|"activates"| Style

    %% S2S Engine
    subgraph "S2S Engine"
        RVC["S2S Engine: RVC"]:::s2s
    end
    S2SHandler -->|"activates"| RVC

    %% API Wrappers for TTS Engines
    subgraph "API Wrappers"
        TortoiseAPI["API Wrapper: TortoiseTTS"]:::api
        F5API["API Wrapper: F5-TTS"]:::api
        StyleAPI["API Wrapper: StyleTTS"]:::api
    end
    TortoiseAPI -.->|"wraps"| Tortoise
    F5API -.->|"wraps"| F5
    StyleAPI -.->|"wraps"| Style

    %% External Dependencies & Deployment
    subgraph "External Dependencies"
        CUDA["CUDA"]:::external
        Torch["torch (version-verified)"]:::external
        FFmpeg["ffmpeg"]:::external
        subgraph "Deployment Scripts"
            Script1["finish_styletts_install.bat"]:::external
            Script2["up.bat"]:::external
            Script3["update_package.bat"]:::external
        end
    end
    Model ---|"requires"| CUDA
    Model ---|"requires"| Torch
    Model ---|"requires"| FFmpeg
    Controller ---|"triggers"| Script1
    Controller ---|"triggers"| Script2
    Controller ---|"triggers"| Script3

    %% Click Events
    click GUI "https://github.com/jarodmica/audiobook_maker/blob/master/src/view.py"
    click Controller "https://github.com/jarodmica/audiobook_maker/blob/master/src/controller.py"
    click Model "https://github.com/jarodmica/audiobook_maker/blob/master/src/model.py"
    click Tortoise "https://github.com/jarodmica/audiobook_maker/tree/master/engines/tortoise"
    click TortoiseAPI "https://github.com/jarodmica/audiobook_maker/tree/master/modules/tortoise_tts_api"
    click F5 "https://github.com/jarodmica/audiobook_maker/tree/master/engines/f5tts"
    click F5API "https://github.com/jarodmica/audiobook_maker/tree/master/modules/F5-TTS"
    click Style "https://github.com/jarodmica/audiobook_maker/tree/master/engines/styletts"
    click StyleAPI "https://github.com/jarodmica/audiobook_maker/tree/master/modules/styletts-api"
    click RVC "https://github.com/jarodmica/audiobook_maker/tree/master/engines/rvc"
    click TTSHandler "https://github.com/jarodmica/audiobook_maker/blob/master/src/tts_engines.py"
    click S2SHandler "https://github.com/jarodmica/audiobook_maker/blob/master/src/s2s_engines.py"
    click Config "https://github.com/jarodmica/audiobook_maker/tree/master/configs"
    click Script1 "https://github.com/jarodmica/audiobook_maker/blob/master/finish_styletts_install.bat"
    click Script2 "https://github.com/jarodmica/audiobook_maker/blob/master/up.bat"
    click Script3 "https://github.com/jarodmica/audiobook_maker/blob/master/update_package.bat"

    %% Styles
    classDef gui fill:#f9c74f,stroke:#f9844a,stroke-width:2px;
    classDef controller fill:#90be6d,stroke:#43aa8b,stroke-width:2px;
    classDef model fill:#f94144,stroke:#f3722c,stroke-width:2px;
    classDef config fill:#577590,stroke:#4d908e,stroke-width:2px;
    classDef handler fill:#277da1,stroke:#4ea1d3,stroke-width:2px;
    classDef tts fill:#f8961e,stroke:#f3722c,stroke-width:2px;
    classDef s2s fill:#90be6d,stroke:#43aa8b,stroke-width:2px;
    classDef api fill:#5f0f40,stroke:#9d0208,stroke-width:2px;
    classDef external fill:#a9def9,stroke:#61a5c2,stroke-width:2px;
```
