# sayass/vits-finetuning architecture

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

- Interactive diagram: https://gitdiagram.com/sayass/vits-finetuning
- Repository: https://github.com/sayass/vits-finetuning

## Overview

##### Main Components
- Data Sources & Datasets – Represented by the wav files (audio samples) in the “wav” directory and filelists (train/validation lists in filelists/). These files are the raw inputs for the training process.
- Configuration – The “configs” folder holds JSON configuration files (e.g., config.json, config-single-speaker.json) that specify model parameters and training settings.
- Preprocessing Pipeline – Scripts such as preprocess.py, mel_processing.py, and text cleaning utilities in the “text” directory (e.g., cleaners.py, japanese.py) handle audio normalization, feature extraction, and text normalization.
- Model & Core Modules – The main model code is in models.py with support from modules.py, losses.py, transforms.py, and additional functionalities in commons.py and utils.py. The “monotonic_align” folder further supports alignment operations crucial for training.
- Training and Inference Engine – The training scripts (train.py, train_ms.py) and inference.ipynb (and optionally webui.py) coordinate the training process and later perform inference using pre-trained checkpoints.
- External Dependencies – The README and requirements.txt indicate dependency on specific Python versions (suggested Python 3.7) and external libraries, as well as integration with external models (via Hugging Face links).

##### Relationships and Interactions
- Data Flow: The pipeline begins with raw wav files and filelists. These are fed into the Preprocessing component where audio and text are cleaned, processed, and converted into the appropriate features.
- Preprocessed Data → Model Training: The processed data is then used by the training scripts which load configurations from the “configs” directory, feed into the model (defined in models.py, modules.py, etc.), and apply losses (losses.py) during training.
- Model Components: The architecture of the VITS model, including generator (G) and discriminator (D), relies on modules such as monotonic_align for alignment; these components are integrated in the model code.
- Inference: Once training is completed, the inference scripts (inference.ipynb, webui.py) utilize pre-trained models and the txt cleaners to generate synthesized speech.

##### Architectural Patterns and Design Principles
- Pipeline Architecture: The design follows a clear pipeline—data ingestion → preprocessing → model training → inference.
- Modularity: Code is divided into clearly defined modules (preprocessing, model definition, training, utilities) allowing independent development and replacement.
- Config-Driven Design: Model parameters and training settings are externalized in JSON configuration files, permitting flexibility without code changes.
- Separation of Concerns: Distinct responsibilities are allocated to directories/files (e.g., text cleaning in the “text” folder separate from model logic in “models.py”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Ingestion"
        DS_wav["wav"] 
        DS_filelists["filelists"]
    end

    subgraph "Preprocessing"
        PP_preprocess["preprocess.py"]
        PP_mel["mel_processing.py"]
        PP_cleaners["text/cleaners.py"]
        PP_japanese["text/japanese.py"]
    end

    subgraph "Configuration"
        CFG["configs"]
    end

    subgraph "Model & Core"
        MC_models["models.py"]
        MC_modules["modules.py"]
        MC_losses["losses.py"]
        MC_transforms["transforms.py"]
        MC_commons["commons.py"]
        MC_utils["utils.py"]
        MC_align["monotonic_align"]
    end

    subgraph "Training and Inference"
        TI_train["train.py"]
        TI_trainms["train_ms.py"]
        TI_inference["inference.ipynb"]
        TI_webui["webui.py"]
    end

    ED_req["requirements.txt"]

    %% Data Flow Connections
    DS_wav -->|"raw_audio"| PP_preprocess
    DS_filelists -->|"filelist"| PP_preprocess

    PP_preprocess -->|"features"| TI_train
    PP_preprocess -->|"features"| TI_trainms

    %% Config flows into training
    CFG -->|"model_config"| TI_train
    CFG -->|"model_config"| TI_trainms

    %% Training connects to Model & Core
    TI_train -->|"trains"| MC_models
    TI_trainms -->|"trains"| MC_modules

    %% Model update flows into inference
    MC_models -->|"trained_model"| TI_inference
    MC_modules -->|"trained_model"| TI_webui

    %% External Dependencies support configuration and training
    ED_req -->|"dependencies"| CFG
    ED_req -->|"dependencies"| TI_train
    ED_req -->|"dependencies"| TI_trainms

    %% Styling Classes
    class DS_wav,DS_filelists data;
    class PP_preprocess,PP_mel,PP_cleaners,PP_japanese preprocessing;
    class CFG config;
    class MC_models,MC_modules,MC_losses,MC_transforms,MC_commons,MC_utils,MC_align model;
    class TI_train,TI_trainms,TI_inference,TI_webui training;
    class ED_req external;

    %% Class Definitions
    classDef data fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef preprocessing fill:#FFECB3,stroke:#FFA000,stroke-width:2px;
    classDef config fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef model fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef training fill:#DCEDC8,stroke:#7CB342,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#E53935,stroke-width:2px;

    %% Click Events
    click DS_wav "https://github.com/sayass/vits-finetuning/tree/main/wav"
    click DS_filelists "https://github.com/sayass/vits-finetuning/tree/main/filelists"
    click PP_preprocess "https://github.com/sayass/vits-finetuning/blob/main/preprocess.py"
    click PP_mel "https://github.com/sayass/vits-finetuning/blob/main/mel_processing.py"
    click PP_cleaners "https://github.com/sayass/vits-finetuning/blob/main/text/cleaners.py"
    click PP_japanese "https://github.com/sayass/vits-finetuning/blob/main/text/japanese.py"
    click CFG "https://github.com/sayass/vits-finetuning/tree/main/configs"
    click MC_models "https://github.com/sayass/vits-finetuning/blob/main/models.py"
    click MC_modules "https://github.com/sayass/vits-finetuning/blob/main/modules.py"
    click MC_losses "https://github.com/sayass/vits-finetuning/blob/main/losses.py"
    click MC_transforms "https://github.com/sayass/vits-finetuning/blob/main/transforms.py"
    click MC_commons "https://github.com/sayass/vits-finetuning/blob/main/commons.py"
    click MC_utils "https://github.com/sayass/vits-finetuning/blob/main/utils.py"
    click MC_align "https://github.com/sayass/vits-finetuning/tree/main/monotonic_align/"
    click TI_train "https://github.com/sayass/vits-finetuning/blob/main/train.py"
    click TI_trainms "https://github.com/sayass/vits-finetuning/blob/main/train_ms.py"
    click TI_inference "https://github.com/sayass/vits-finetuning/blob/main/inference.ipynb"
    click TI_webui "https://github.com/sayass/vits-finetuning/blob/main/webui.py"
    click ED_req "https://github.com/sayass/vits-finetuning/blob/main/requirements.txt"
```
