# tigregotico/pyahotts architecture

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

- Interactive diagram: https://gitdiagram.com/tigregotico/pyahotts
- Repository: https://github.com/tigregotico/pyahotts

## Overview

##### Project Overview
- AhoTTS is a text-to-speech converter for Basque and Spanish.
- It is a hybrid system: it combines Python bindings (the “pyahotts” package) with a native acoustic engine coded in C/C++ (located in the “src” directory) that implements the core functionality (based on hts_engine and the high-quality vocoder “AhoCoder”).
- The system uses prebuilt voices, linguistic data (dictionaries, PDFs, inf files, etc.), and both language-specific (Basque and Spanish) resources embedded in the package structure.

##### Main Components
a. Python Bindings Layer:
- Module: “pyahotts”
- Files: __init__.py, version.py, setup.py
- This layer provides a high-level API (as shown in the README’s usage example) and wraps calls to the underlying native libraries.

b. Native Engine / Acoustics Module:
- Source directory (“src”) contains all of the C/C++ code for the HTS engine, AhoCoder functionality, and linguistic processing (e.g., files like HTS_ahocoder.c, HTS_audio.c, etc.).
- This module is responsible for processing input text and producing the audio output.

c. Language Resources:
- Data and models stored under “pyahotts/data_tts”; includes dictionaries (for Spanish and Basque) and voice models (organized further into “aholab_es_female” and “aholab_eu_female”).
- These provide the data for linguistic, prosodic, and acoustic processing.

d. Build/Deployment/CI Components:
- “CMakeLists.txt” at the top level and within “src” for building the native libraries.
- “.github” workflows for tests, releases, and publishing which showcase continuous integration.

##### Mapping Component Relationships
- The Python bindings (pyahotts) call into the native library (compiled from the “src” files) using mechanisms such as dynamic linking.
- The native TTS engine uses the language resources (dictionaries, voice files, etc.) for synthesis.
- The build system (using CMake) coordinates compilation and packaging of the native engine while the “setup.py” may tie everything together for installation via Python’s packaging ecosystem.
- CI/CD (via GitHub workflows) is used for ensuring code quality and handling releases.

##### Architectural Patterns & Important Elements
- Layered Architecture: Clear separation between the high-level Python interface and the low-level native processing components.
- Modular Organization: Each subsystem (Python bindings, native engine, data resources, build scripts) is self-contained. This eases maintenance and potential extension (for example, adding new voice models or supporting additional languages).
- The system adheres to a plug-in-like approach when it comes to its voice models and dictionaries – different voices and language-specific resources are organized in separate directories and are loaded based on user input (e.g., “lang” parameter).

##### Technologies & Frameworks
- C/C++ (with CMake build system) for the core HTS engine and vocoder (AhoCoder).
- Python for bindings and high-level API.
- The project uses CI tools defined within GitHub workflows (e.g., conventional-label, install_tests, publish_stable).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Python Bindings Layer"
        A["Text-to-Speech API (pyahotts)"]:::python
        B["Package Integration (setup.py)"]:::python
    end

    subgraph "Native Engine (C/C++ Module)"
        C["HTS Engine & AhoCoder (src)"]:::native
    end

    subgraph "Language Resources"
        D["Voice Models & Dictionaries (data_tts)"]:::data
    end

    subgraph "Build & CI/CD"
        E["CMake Build (CMakeLists.txt)"]:::build
        F["GitHub Workflows"]:::ci
    end

    A -->|"calls"| C
    C -->|"uses"| D
    B -->|"integratesWith"| E
    E -->|"builds"| C
    F -->|"testsAndDeploys"| A
    F -->|"orchestrates"| E

    click A "https://github.com/tigregotico/pyahotts/blob/dev/pyahotts/__init__.py"
    click B "https://github.com/tigregotico/pyahotts/blob/dev/setup.py"
    click C "https://github.com/tigregotico/pyahotts/tree/dev/src"
    click D "https://github.com/tigregotico/pyahotts/tree/dev/pyahotts/data_tts"
    click E "https://github.com/tigregotico/pyahotts/blob/dev/CMakeLists.txt"
    click F "https://github.com/tigregotico/pyahotts/tree/dev/.github/workflows"

    classDef python fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef native fill:#A9DFBF,stroke:#229954,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef build fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef ci fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
