# freyavoiceai/freyatts architecture

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

- Interactive diagram: https://gitdiagram.com/freyavoiceai/freyatts
- Repository: https://github.com/freyavoiceai/freyatts

## Overview

FreyaTTS-small is a Turkish text-to-speech model whose main runtime path turns text into 48 kHz speech: the pipeline normalizes and splits text, predicts latent duration, runs the flow-matching DiT, and decodes latents with a frozen AudioVAE. The repository also contains latent-data preparation, pretraining and two SFT stages, plus a speed benchmark. Edges are limited to relationships shown in excerpts or documented in the README; unsampled implementation details are not inferred.

Main entry points: [`freyatts/pipeline.py`](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/pipeline.py) (Synthesis pipeline), [`freyatts/vae.py`](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/vae.py) (Frozen AudioVAE), [`batch_infer.py`](https://github.com/freyavoiceai/freyatts/blob/main/batch_infer.py) (Batch inference), [`training/extract_short_segments.py`](https://github.com/freyavoiceai/freyatts/blob/main/training/extract_short_segments.py) (Short-segment extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Speech synthesis"]
  node_cli["CLI inference<br/>[infer.py]"]
  node_batch["Batch inference<br/>[batch_infer.py]"]
  node_pipeline["Synthesis pipeline<br/>[pipeline.py]"]
  node_normalization["Text normalization<br/>[pipeline.py]"]
end

subgraph group_model["Model components"]
  node_di["Flow-matching DiT<br/>[model.py]"]
  node_vocab["Character vocabulary<br/>[char_vocab.json]"]
  node_vae["Frozen AudioVAE<br/>[vae.py]"]
end

subgraph group_training["Training pipeline"]
  node_audio_manifest["Audio/text manifest"]
  node_latent_prep["Latent precomputation"]
  node_short_segments["Short-segment extraction"]
  node_latent_store[("Latent shards")]
  node_pretrain["Pretraining<br/>[pretrain.py]"]
  node_sft["SFT stages<br/>[sft.py]"]
  node_sft_configs["SFT configurations"]
end

subgraph group_evaluation["Evaluation"]
  node_benchmark["Speed benchmark<br/>[speed.py]"]
  node_benchmark_results["Benchmark results"]
end

node_user(("Text caller"))
node_vae_service[("VoxCPM2 AudioVAE weights")]
node_waveform["48 kHz waveform"]

node_user -->|"provides text"| node_cli
node_cli -->|"invokes"| node_pipeline
node_user -->|"provides texts"| node_batch
node_batch -->|"runs denoising"| node_di
node_batch -->|"decodes latents"| node_vae
node_pipeline -->|"normalizes text"| node_normalization
node_pipeline -->|"predicts latents"| node_di
node_pipeline -->|"decodes latents"| node_vae
node_pipeline -->|"loads vocabulary"| node_vocab
node_pipeline -->|"returns audio"| node_waveform
node_batch -->|"writes audio"| node_waveform
node_vae -->|"loads weights"| node_vae_service
node_audio_manifest -->|"supplies clips"| node_latent_prep
node_latent_prep -->|"encodes audio"| node_vae
node_latent_prep -->|"writes shards"| node_latent_store
node_audio_manifest -->|"supplies clips"| node_short_segments
node_short_segments -->|"encodes segments"| node_vae
node_short_segments -->|"writes shards"| node_latent_store
node_latent_store -->|"provides training data"| node_pretrain
node_pretrain -->|"trains model"| node_di
node_pretrain -->|"initializes stages"| node_sft
node_latent_store -->|"provides training data"| node_sft
node_short_segments -->|"adds stage-two data"| node_sft
node_sft_configs -->|"configures stages"| node_sft
node_benchmark -->|"measures synthesis"| node_pipeline
node_benchmark -->|"reports metrics"| node_benchmark_results

click node_cli "https://github.com/freyavoiceai/freyatts/blob/main/infer.py"
click node_batch "https://github.com/freyavoiceai/freyatts/blob/main/batch_infer.py"
click node_pipeline "https://github.com/freyavoiceai/freyatts/blob/main/freyatts/pipeline.py"
click node_normalization "https://github.com/freyavoiceai/freyatts/blob/main/freyatts/pipeline.py"
click node_di "https://github.com/freyavoiceai/freyatts/blob/main/freyatts/model.py"
click node_vocab "https://github.com/freyavoiceai/freyatts/blob/main/freyatts/char_vocab.json"
click node_vae "https://github.com/freyavoiceai/freyatts/blob/main/freyatts/vae.py"
click node_latent_prep "https://github.com/freyavoiceai/freyatts/blob/main/training/precompute_latents.py"
click node_short_segments "https://github.com/freyavoiceai/freyatts/blob/main/training/extract_short_segments.py"
click node_pretrain "https://github.com/freyavoiceai/freyatts/blob/main/training/pretrain.py"
click node_sft "https://github.com/freyavoiceai/freyatts/blob/main/training/sft.py"
click node_sft_configs "https://github.com/freyavoiceai/freyatts/tree/main/training/configs"
click node_benchmark "https://github.com/freyavoiceai/freyatts/blob/main/eval/speed.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_cli,node_batch,node_pipeline,node_normalization toneBlue
class node_di,node_vocab,node_vae,node_vae_service toneAmber
class node_audio_manifest,node_latent_prep,node_short_segments,node_latent_store,node_pretrain,node_sft,node_sft_configs toneMint
class node_benchmark,node_benchmark_results toneRose
class node_user,node_waveform toneIndigo
```

## Components

### Speech synthesis

- [CLI inference](https://github.com/freyavoiceai/freyatts/blob/main/infer.py): `infer.py`
- [Batch inference](https://github.com/freyavoiceai/freyatts/blob/main/batch_infer.py): `batch_infer.py`
- [Synthesis pipeline](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/pipeline.py): `freyatts/pipeline.py`
- [Text normalization](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/pipeline.py): `freyatts/pipeline.py`

### Model components

- [Flow-matching DiT](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/model.py): `freyatts/model.py`
- [Character vocabulary](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/char_vocab.json): `freyatts/char_vocab.json`
- [Frozen AudioVAE](https://github.com/freyavoiceai/freyatts/blob/main/freyatts/vae.py): `freyatts/vae.py`

### Training pipeline

- **Audio/text manifest**
- [Latent precomputation](https://github.com/freyavoiceai/freyatts/blob/main/training/precompute_latents.py): `training/precompute_latents.py`
- [Short-segment extraction](https://github.com/freyavoiceai/freyatts/blob/main/training/extract_short_segments.py): `training/extract_short_segments.py`
- **Latent shards**
- [Pretraining](https://github.com/freyavoiceai/freyatts/blob/main/training/pretrain.py): `training/pretrain.py`
- [SFT stages](https://github.com/freyavoiceai/freyatts/blob/main/training/sft.py): `training/sft.py`
- [SFT configurations](https://github.com/freyavoiceai/freyatts/tree/main/training/configs): `training/configs`

### Evaluation

- [Speed benchmark](https://github.com/freyavoiceai/freyatts/blob/main/eval/speed.py): `eval/speed.py`
- **Benchmark results**

### Other components

- **Text caller**
- **VoxCPM2 AudioVAE weights**
- **48 kHz waveform**

## Connections

- Text caller → CLI inference: provides text (evidence: `README.md`)
- CLI inference → Synthesis pipeline: invokes (evidence: `infer.py`)
- Text caller → Batch inference: provides texts (evidence: `README.md`)
- Batch inference → Flow-matching DiT: runs denoising (evidence: `batch_infer.py`)
- Batch inference → Frozen AudioVAE: decodes latents (evidence: `batch_infer.py`)
- Synthesis pipeline → Text normalization: normalizes text (evidence: `freyatts/pipeline.py`)
- Synthesis pipeline → Flow-matching DiT: predicts latents (evidence: `freyatts/pipeline.py`)
- Synthesis pipeline → Frozen AudioVAE: decodes latents (evidence: `freyatts/pipeline.py`)
- Synthesis pipeline → Character vocabulary: loads vocabulary (evidence: `freyatts/pipeline.py`)
- Synthesis pipeline → 48 kHz waveform: returns audio (evidence: `README.md`)
- Batch inference → 48 kHz waveform: writes audio (evidence: `batch_infer.py`)
- Frozen AudioVAE → VoxCPM2 AudioVAE weights: loads weights (evidence: `freyatts/vae.py`)
- Audio/text manifest → Latent precomputation: supplies clips (evidence: `README.md`)
- Latent precomputation → Frozen AudioVAE: encodes audio (evidence: `training/precompute_latents.py`)
- Latent precomputation → Latent shards: writes shards (evidence: `training/precompute_latents.py`)
- Audio/text manifest → Short-segment extraction: supplies clips (evidence: `training/extract_short_segments.py`)
- Short-segment extraction → Frozen AudioVAE: encodes segments (evidence: `training/extract_short_segments.py`)
- Short-segment extraction → Latent shards: writes shards (evidence: `training/extract_short_segments.py`)
- Latent shards → Pretraining: provides training data (evidence: `training/pretrain.py`)
- Pretraining → Flow-matching DiT: trains model (evidence: `training/pretrain.py`)
- Pretraining → SFT stages: initializes stages (evidence: `README.md`)
- Latent shards → SFT stages: provides training data (evidence: `training/sft.py`)
- Short-segment extraction → SFT stages: adds stage-two data (evidence: `training/extract_short_segments.py`)
- SFT configurations → SFT stages: configures stages (evidence: `README.md`)
- Speed benchmark → Synthesis pipeline: measures synthesis (evidence: `eval/speed.py`)
- Speed benchmark → Benchmark results: reports metrics (evidence: `eval/speed.py`)
