# onkarwakchaure/text-to-speech-ai architecture

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

- Interactive diagram: https://gitdiagram.com/onkarwakchaure/text-to-speech-ai
- Repository: https://github.com/onkarwakchaure/text-to-speech-ai

## Overview

Text To Speech AI is a FastAPI web app for generating English and Hindi speech, with either a built-in voice or an uploaded voice sample for cloning. The main workflow is browser form → `/generate` → optional MP3-to-WAV input conversion → XTTS synthesis → WAV-to-MP3 output → browser playback or download. The README also documents temporary-file cleanup and the static web interface. The source excerpt is limited to `main.py`; UI behavior beyond the documented capabilities is not inferred.

Main entry points: [`main.py`](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py) (FastAPI app), [`templates/index.html`](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/templates/index.html) (Web interface), [`static`](https://github.com/onkarwakchaure/text-to-speech-ai/tree/main/static) (Static assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_interface["Web interface<br/>[index.html]"]
  node_static["Static assets"]
  node_playback["Playback and download<br/>[index.html]"]
end

subgraph group_api["Speech API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_form["Speech request<br/>[main.py]"]
  node_model["XTTS v2<br/>[main.py]"]
end

subgraph group_audio["Audio processing"]
  node_voice["Voice sample<br/>[main.py]"]
  node_input_convert["MP3 to WAV<br/>[main.py]"]
  node_synthesis["Speech synthesis<br/>[main.py]"]
  node_output_convert["WAV to MP3<br/>[main.py]"]
  node_audio_libs["Pydub and FFmpeg<br/>[main.py]"]
end

subgraph group_storage["Audio files"]
  node_input_upload[("Uploaded audio<br/>[main.py]")]
  node_wav_temp[("Temporary WAV<br/>[main.py]")]
  node_mp3_output[("Generated MP3<br/>[main.py]")]
end

node_user(("User"))

node_user -->|"uses"| node_interface
node_interface -.->|"submits request"| node_fastapi
node_fastapi -->|"serves page"| node_interface
node_fastapi -->|"mounts assets"| node_static
node_fastapi -->|"routes generation"| node_form
node_form -->|"writes upload"| node_input_upload
node_form -->|"selects sample"| node_voice
node_input_upload -->|"reads MP3"| node_input_convert
node_input_convert -->|"converts audio"| node_audio_libs
node_input_convert -->|"produces WAV"| node_voice
node_form -->|"invokes"| node_synthesis
node_voice -->|"conditions voice"| node_synthesis
node_synthesis -->|"calls XTTS"| node_model
node_synthesis -->|"writes WAV"| node_wav_temp
node_wav_temp -->|"reads WAV"| node_output_convert
node_output_convert -->|"converts audio"| node_audio_libs
node_output_convert -->|"writes MP3"| node_mp3_output
node_mp3_output -.->|"serves audio"| node_playback
node_playback -->|"plays or downloads"| node_user

click node_interface "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/templates/index.html"
click node_static "https://github.com/onkarwakchaure/text-to-speech-ai/tree/main/static"
click node_fastapi "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_form "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_model "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_voice "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_input_upload "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_input_convert "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_synthesis "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_wav_temp "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_output_convert "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_mp3_output "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"
click node_playback "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/templates/index.html"
click node_audio_libs "https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_interface,node_static,node_playback,node_user toneBlue
class node_fastapi,node_form,node_model toneAmber
class node_voice,node_input_convert,node_synthesis,node_output_convert,node_audio_libs toneMint
class node_input_upload,node_wav_temp,node_mp3_output toneRose
```

## Components

### Web interface

- [Web interface](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/templates/index.html): `templates/index.html`
- [Static assets](https://github.com/onkarwakchaure/text-to-speech-ai/tree/main/static): `static`
- [Playback and download](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/templates/index.html): `templates/index.html`

### Speech API

- [FastAPI app](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [Speech request](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [XTTS v2](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`

### Audio processing

- [Voice sample](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [MP3 to WAV](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [Speech synthesis](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [WAV to MP3](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [Pydub and FFmpeg](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`

### Audio files

- [Uploaded audio](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [Temporary WAV](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`
- [Generated MP3](https://github.com/onkarwakchaure/text-to-speech-ai/blob/main/main.py): `main.py`

### Other components

- **User**

## Connections

- User → Web interface: uses (evidence: `README.md`)
- Web interface → FastAPI app: submits request (evidence: `README.md`)
- FastAPI app → Web interface: serves page (evidence: `main.py`)
- FastAPI app → Static assets: mounts assets (evidence: `main.py`)
- FastAPI app → Speech request: routes generation (evidence: `main.py`)
- Speech request → Uploaded audio: writes upload (evidence: `main.py`)
- Speech request → Voice sample: selects sample (evidence: `main.py`)
- Uploaded audio → MP3 to WAV: reads MP3 (evidence: `main.py`)
- MP3 to WAV → Pydub and FFmpeg: converts audio (evidence: `main.py`)
- MP3 to WAV → Voice sample: produces WAV (evidence: `main.py`)
- Speech request → Speech synthesis: invokes (evidence: `main.py`)
- Voice sample → Speech synthesis: conditions voice (evidence: `main.py`)
- Speech synthesis → XTTS v2: calls XTTS (evidence: `main.py`)
- Speech synthesis → Temporary WAV: writes WAV (evidence: `main.py`)
- Temporary WAV → WAV to MP3: reads WAV (evidence: `main.py`)
- WAV to MP3 → Pydub and FFmpeg: converts audio (evidence: `main.py`)
- WAV to MP3 → Generated MP3: writes MP3 (evidence: `main.py`)
- Generated MP3 → Playback and download: serves audio (evidence: `README.md`)
- Playback and download → User: plays or downloads (evidence: `README.md`)
