# theyaxh/svar-text-to-speech architecture

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

- Interactive diagram: https://gitdiagram.com/theyaxh/svar-text-to-speech
- Repository: https://github.com/theyaxh/svar-text-to-speech

## Overview

##### Project Type and Purpose
- The README clarifies that the repository implements a text-to-speech engine focusing initially on Gujarati, with potential expansion to other Indian languages.
- The repository is modularized into various processing stages, indicating a pipeline-based architecture.

##### File Structure
- Four main directories represent the core components:
- “tokenization” contains the Gujarati tokenizer (tokenization/gujarati_tokenizer.py and a testcase), which is responsible for breaking down the text into manageable tokens.
- “preprocessing-and-normalization” includes files for preprocessor and normalizer modules, preparing and cleaning the text for further processing.
- “grapheme2phoneme” has a module (g2p.py) for converting text (graphemes) into phonemes, which is essential for accurate pronunciation.
- “prosody” contains the prosody module, likely aimed at adding rhythm, intonation, or stress patterns to the phonetic sequence.
- Notice that each module includes its respective test script, underscoring a design that isolates components for easy testing and iteration.

##### README for Additional Insights
- The project description indicates that the engine is under development with a focus on language-specific challenges.
- This confirms a modular approach, where each processing stage (from tokenization to phonetic conversion and prosody) represents a key segment in the TTS pipeline.

a. Main Components:
- Input (Raw Gujarati Text) Source.
- Tokenization Module: Handles splitting the raw text into language tokens.
- Preprocessing & Normalization Module: Cleans and standardizes input tokens (includes “preprocessor” and “normalizer”).
- Grapheme-to-Phoneme (G2P) Module: Converts tokens/words into corresponding phonetic representations.
- Prosody Module: Adds prosodic features (e.g., stress, intonation) to the phonetic output.
- (Optionally, an Output/Synthesis block could be added later when integrating the audio synthesis model.)

b. Relationships and Interactions:
-- Raw text is fed into the tokenization component.
-- Tokenized output flows into preprocessing & normalization.
-- Normalized text is passed to the grapheme-to-phoneme converter.
-- The generated phonemes are refined by the prosody module.
-- Finally, the output (phonetic stream with prosodic cues) can be used by the TTS engine to synthesize speech.

c. Important Architectural Patterns:
- The pipeline emphasizes the separation of concerns: each module is responsible for a distinct part of the process, which makes testing and future enhancements easier.
- Modular design encourages reusability and independent development.
- Interfaces between the stages (e.g., what data type flows between modules).

d. Relevant Technologies, Frameworks, or Libraries:
- Mention that the tests in each module ensure the correctness of isolated components, aligning with modular design principles.

##### Final Representation
- Layout: Start at the left with the “Input” and progress rightwards through the pipeline stages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Raw["Raw Gujarati Text"]:::input
    Tokenizer["Tokenizer (Gujarati)"]:::token
    subgraph "Preprocessing & Normalization"
        Preprocessor["Preprocessor"]:::preprocess
        Normalizer["Normalizer"]:::preprocess
    end
    G2P["Grapheme-to-Phoneme Converter"]:::transformation
    Prosody["Prosody Analyzer"]:::prosody
    Output["Speech Synthesis Ready Phonetic Stream"]:::output

    Raw --> Tokenizer
    Tokenizer --> Preprocessor
    Preprocessor --> Normalizer
    Normalizer --> G2P
    G2P --> Prosody
    Prosody --> Output

    click Tokenizer "https://github.com/theyaxh/svar-text-to-speech/blob/main/tokenization/gujarati_tokenizer.py"
    click Preprocessor "https://github.com/theyaxh/svar-text-to-speech/blob/main/preprocessing-and-normalization/preprocessor.py"
    click Normalizer "https://github.com/theyaxh/svar-text-to-speech/blob/main/preprocessing-and-normalization/normalizer.py"
    click G2P "https://github.com/theyaxh/svar-text-to-speech/blob/main/grapheme2phoneme/g2p.py"
    click Prosody "https://github.com/theyaxh/svar-text-to-speech/blob/main/prosody/prosody.py"

    classDef input fill:#E0E0E0,stroke:#333,stroke-width:2px;
    classDef token fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef preprocess fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef transformation fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef prosody fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef output fill:#E0E0E0,stroke:#333,stroke-width:2px;
```
