# daswer123/rvc-python architecture

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

- Interactive diagram: https://gitdiagram.com/daswer123/rvc-python
- Repository: https://github.com/daswer123/rvc-python

## Overview

##### Project Type and Purpose
- This is a Python-based voice conversion toolkit (RVC Python) that provides:
- A command-line interface (CLI) for batch or single-file processing
- A Python library for embedding in other applications
- An HTTP API server for remote/in-process inference
- Its core function is to load a pre-trained voice conversion model, run audio through a configurable inference pipeline (feature extraction, pitch prediction, synthesis), and output converted audio.

##### File Structure Analysis
- Top-level:
- rvc_python/ – main package
- README.md, pyproject.toml, requirements.txt – metadata & dependencies
- test.py – ad hoc script (likely for quick tests)
- rvc_python/__main__.py – entrypoint dispatching to CLI or API
- rvc_python/api.py – HTTP server implementation and route definitions
- rvc_python/infer.py & infer_old.py – high-level inference class (RVCInference) and older variant
- rvc_python/download_model.py – model downloader
- rvc_python/configs/… – JSON config templates for model versions (v1/v2) and sample rates
- rvc_python/lib/ – shared utilities:
- audio.py – I/O and waveform helpers
- globals.py – global constants
- infer_pack/ – backend-agnostic inference modules (Torch, ONNX, DML)
- jit/ – functions to JIT-compile submodules (hubert, rmvpe, synthesizer)
- rvc_python/modules/ – specialized modules:
- ipex/ – Intel-extension hooks for attention, gradscaler, hijacks
- onnx/ – ONNX export helpers
- train/ – preprocessing scripts for training
- vc/ – core conversion pipeline modules and utilities

##### README Insights
- Describes CLI and API modes, model management, configurable parameters, GPU setup.
- Lists API endpoints for conversion, model loading/listing, parameter get/set, model upload, device selection.
- Highlights dynamic model loading/unloading and support for CPU/GPU.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Client"]:::ui
        API["HTTP API Server"]:::ui
    end

    %% Controller / Entrypoints
    DISPATCH["Dispatcher (__main__.py)"]:::core
    click DISPATCH "https://github.com/daswer123/rvc-python/blob/main/rvc_python/__main__.py"
    click API "https://github.com/daswer123/rvc-python/blob/main/rvc_python/api.py"

    %% Core Library
    subgraph "Core Library"
        RVCI["RVCInference (infer.py)"]:::core
        LegacyI["LegacyInference (infer_old.py)"]:::core
        ModelDL["Model Downloader"]:::core
        click RVCI "https://github.com/daswer123/rvc-python/blob/main/rvc_python/infer.py"
        click LegacyI "https://github.com/daswer123/rvc-python/blob/main/rvc_python/infer_old.py"
        click ModelDL "https://github.com/daswer123/rvc-python/blob/main/rvc_python/download_model.py"
    end

    %% Storage & Configs
    subgraph "Storage & Configs"
        ConfigLoader["Config Loader (config.py)"]:::storage
        Configs["Version Configs (v1/v2 JSON)"]:::storage
        ModelStore["Model Storage (rvc_models/)"]:::storage
        click ConfigLoader "https://github.com/daswer123/rvc-python/blob/main/rvc_python/configs/config.py"
        click Configs "https://github.com/daswer123/rvc-python/tree/main/rvc_python/configs/v1/"
    end

    %% Compute Engines & Modules
    subgraph "Compute & Modules"
        AudioIO["Audio I/O (audio.py)"]:::compute
        Transforms["Pre-processing & Transforms"]:::compute
        Commons["Backend Commons"]:::compute
        TorchBE["Torch Backend"]:::compute
        ONNXBE["ONNX Backend"]:::compute
        DMLBE["DirectML Backend"]:::compute

        subgraph "F0 Predictors"
            F0Base["F0Predictor Base"]:::module
            Harvest["Harvest Predictor"]:::module
            Dio["Dio Predictor"]:::module
            PM["PM Predictor"]:::module
        end

        subgraph "JIT Submodules"
            JITHub["Hubert JIT"]:::module
            JITRM["RMVPE JIT"]:::module
            JITSyn["Synthesizer JIT"]:::module
        end

        subgraph "Extensions & Helpers"
            IPEX["Intel Extension Hooks"]:::module
            ONNXExp["ONNX Export Helper"]:::module
            TrainPre["Training Preprocess"]:::module
            VCPipe["VC Pipeline"]:::module
            VCUtils["VC Utilities"]:::module
        end

        click AudioIO "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/audio.py"
        click Transforms "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/transforms.py"
        click Commons "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/commons.py"
        click TorchBE "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/models.py"
        click ONNXBE "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/models_onnx.py"
        click DMLBE "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/models_dml.py"
        click F0Base "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/modules/F0Predictor/F0Predictor.py"
        click Harvest "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/modules/F0Predictor/HarvestF0Predictor.py"
        click Dio "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/modules/F0Predictor/DioF0Predictor.py"
        click PM "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/infer_pack/modules/F0Predictor/PMF0Predictor.py"
        click JITHub "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/jit/get_hubert.py"
        click JITRM "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/jit/get_rmvpe.py"
        click JITSyn "https://github.com/daswer123/rvc-python/blob/main/rvc_python/lib/jit/get_synthesizer.py"
        click IPEX "https://github.com/daswer123/rvc-python/blob/main/rvc_python/modules/ipex/attention.py"
        click ONNXExp "https://github.com/daswer123/rvc-python/blob/main/rvc_python/modules/onnx/export.py"
        click TrainPre "https://github.com/daswer123/rvc-python/blob/main/rvc_python/modules/train/preprocess.py"
        click VCPipe "https://github.com/daswer123/rvc-python/blob/main/rvc_python/modules/vc/pipeline.py"
        click VCUtils "https://github.com/daswer123/rvc-python/blob/main/rvc_python/modules/vc/utils.py"
    end

    %% Relationships
    CLI --> DISPATCH
    API --> RVCI
    DISPATCH --> RVCI
    RVCI --> AudioIO
    AudioIO --> Transforms
    Transforms --> F0Base
    F0Base --> Harvest
    F0Base --> Dio
    F0Base --> PM
    Transforms --> Commons
    Commons --> TorchBE
    Commons --> ONNXBE
    Commons --> DMLBE
    TorchBE --> JITHub
    TorchBE --> JITRM
    TorchBE --> JITSyn
    RVCI --> ModelDL
    ModelDL --> ModelStore
    RVCI --> ConfigLoader
    ConfigLoader --> Configs
    API --> ModelStore
    API --> RVCI
    API --> RVCI
    RVCI --> VCPipe
    VCPipe --> VCUtils
    RVCI --> IPEX
    RVCI --> ONNXExp
    RVCI --> TrainPre

    classDef ui fill:#D6E4FF,stroke:#4096FF
    classDef core fill:#E3FCEF,stroke:#2BAF66
    classDef storage fill:#FFF4E6,stroke:#D9480F
    classDef compute fill:#FFF5F5,stroke:#F03E3E
    classDef module fill:#E7E5F7,stroke:#5F3DC4
```
