# venuaditya/whisperspeech architecture

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

- Interactive diagram: https://gitdiagram.com/venuaditya/whisperspeech
- Repository: https://github.com/venuaditya/whisperspeech

## Overview

WhisperSpeech is a two-stage, token-based text-to-speech system: text is converted to semantic tokens, then acoustic tokens are generated and rendered as audio. Its repository also contains model training and speech-data preparation workflows, including voice-activity detection and speaker-embedding extraction. The README documents the semantic, acoustic, and vocoder stages; source-index references support several preparation and model dependencies. Some central modules, including the main pipeline and model-fetching code, were not excerpted, so their runtime wiring is not asserted here.

Main entry points: [`whisperspeech/s2a_delar_mup_wds_mlang.py`](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/s2a_delar_mup_wds_mlang.py) (Semantic-to-acoustic model), [`whisperspeech/inference.py`](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/inference.py) (Inference utilities), [`whisperspeech/t2s_up_wds_mlang_enclm.py`](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/t2s_up_wds_mlang_enclm.py) (Text-to-semantic model), [`whisperspeech/modules.py`](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/modules.py) (Neural building blocks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Speech generation"]
  node_pipeline["TTS pipeline<br/>[pipeline.py]"]
  node_audio["Audio rendering<br/>[a2wav.py]"]
  node_inference["Inference utilities<br/>[inference.py]"]
end

subgraph group_models["Models and training"]
  node_semantic["Semantic tokens<br/>[vq_stoks.py]"]
  node_text_semantic["Text-to-semantic model"]
  node_acoustic["Semantic-to-acoustic model"]
  node_conditioned_acoustic["Conditioned acoustic model"]
  node_modules["Neural building blocks<br/>[modules.py]"]
  node_languages["Language mapping<br/>[languages.py]"]
  node_train["Model training<br/>[train.py]"]
  node_train_multi["Distributed training<br/>[train_multi.py]"]
end

subgraph group_data["Speech data preparation"]
  node_vad["Voice activity detection<br/>[vad.py]"]
  node_vad_merge["VAD segment merging<br/>[vad_merge.py]"]
  node_transcribe["Whisper transcription<br/>[wh_transcribe.py]"]
  node_speaker_embeddings["Speaker embeddings<br/>[extract_spk_emb.py]"]
  node_extract_stoks["Semantic-token extraction<br/>[extract_stoks.py]"]
  node_prepare_t2s["Text-model data prep"]
  node_prepare_s2a["Acoustic-model data prep"]
end

subgraph group_evaluation["Evaluation and metrics"]
  node_testing["Model testing<br/>[testing.py]"]
  node_metrics["Speech metrics<br/>[extract_metrics.py]"]
end

node_user(("Text-to-speech user"))
node_whisper{{"Whisper"}}
node_encodec{{"EnCodec"}}
node_vocos{{"Vocos"}}

node_user -.->|"requests speech"| node_pipeline
node_pipeline -.->|"generates semantic tokens"| node_text_semantic
node_text_semantic -.->|"conditions generation"| node_acoustic
node_acoustic -.->|"renders audio"| node_audio
node_audio -->|"uses utilities"| node_inference
node_semantic -->|"transcription to tokens"| node_whisper
node_encodec -->|"tokenizes waveform"| node_acoustic
node_vocos -->|"synthesizes audio"| node_audio
node_text_semantic -->|"uses building blocks"| node_modules
node_text_semantic -->|"uses language IDs"| node_languages
node_acoustic -->|"uses building blocks"| node_modules
node_acoustic -->|"uses language IDs"| node_languages
node_conditioned_acoustic -->|"uses building blocks"| node_modules
node_conditioned_acoustic -->|"uses language IDs"| node_languages
node_vad -->|"selects compute device"| node_inference
node_transcribe -->|"uses VAD"| node_vad
node_transcribe -->|"selects compute device"| node_inference
node_speaker_embeddings -->|"uses VAD"| node_vad
node_speaker_embeddings -->|"uses utilities"| node_inference
node_extract_stoks -->|"extracts tokens"| node_semantic
node_extract_stoks -->|"uses merged segments"| node_vad_merge
node_prepare_t2s -->|"uses merged segments"| node_vad_merge
node_prepare_s2a -->|"uses merged segments"| node_vad_merge
node_train -->|"uses utilities"| node_modules
node_train_multi -->|"uses testing"| node_testing
node_metrics -->|"uses token model"| node_semantic
node_metrics -->|"uses merged segments"| node_vad_merge
node_metrics -->|"uses utilities"| node_inference

click node_pipeline "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/pipeline.py"
click node_semantic "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vq_stoks.py"
click node_text_semantic "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/t2s_up_wds_mlang_enclm.py"
click node_acoustic "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/s2a_delar_mup_wds_mlang.py"
click node_conditioned_acoustic "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/s2a_delar_mup_wds_mlang_cond.py"
click node_audio "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/a2wav.py"
click node_inference "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/inference.py"
click node_modules "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/modules.py"
click node_languages "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/languages.py"
click node_vad "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vad.py"
click node_vad_merge "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vad_merge.py"
click node_transcribe "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/wh_transcribe.py"
click node_speaker_embeddings "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_spk_emb.py"
click node_extract_stoks "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_stoks.py"
click node_prepare_t2s "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/prepare_t2s_txts.py"
click node_prepare_s2a "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/prepare_s2a_atoks.py"
click node_train "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/train.py"
click node_train_multi "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/train_multi.py"
click node_testing "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/testing.py"
click node_metrics "https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_metrics.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_pipeline,node_audio,node_inference,node_user toneBlue
class node_semantic,node_text_semantic,node_acoustic,node_conditioned_acoustic,node_modules,node_languages,node_train,node_train_multi toneAmber
class node_vad,node_vad_merge,node_transcribe,node_speaker_embeddings,node_extract_stoks,node_prepare_t2s,node_prepare_s2a toneMint
class node_testing,node_metrics toneRose
class node_whisper,node_encodec,node_vocos toneIndigo
```

## Components

### Speech generation

- [TTS pipeline](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/pipeline.py): `whisperspeech/pipeline.py`
- [Audio rendering](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/a2wav.py): `whisperspeech/a2wav.py`
- [Inference utilities](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/inference.py): `whisperspeech/inference.py`

### Models and training

- [Semantic tokens](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vq_stoks.py): `whisperspeech/vq_stoks.py`
- [Text-to-semantic model](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/t2s_up_wds_mlang_enclm.py): `whisperspeech/t2s_up_wds_mlang_enclm.py`
- [Semantic-to-acoustic model](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/s2a_delar_mup_wds_mlang.py): `whisperspeech/s2a_delar_mup_wds_mlang.py`
- [Conditioned acoustic model](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/s2a_delar_mup_wds_mlang_cond.py): `whisperspeech/s2a_delar_mup_wds_mlang_cond.py`
- [Neural building blocks](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/modules.py): `whisperspeech/modules.py`
- [Language mapping](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/languages.py): `whisperspeech/languages.py`
- [Model training](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/train.py): `whisperspeech/train.py`
- [Distributed training](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/train_multi.py): `whisperspeech/train_multi.py`

### Speech data preparation

- [Voice activity detection](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vad.py): `whisperspeech/vad.py`
- [VAD segment merging](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/vad_merge.py): `whisperspeech/vad_merge.py`
- [Whisper transcription](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/wh_transcribe.py): `whisperspeech/wh_transcribe.py`
- [Speaker embeddings](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_spk_emb.py): `whisperspeech/extract_spk_emb.py`
- [Semantic-token extraction](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_stoks.py): `whisperspeech/extract_stoks.py`
- [Text-model data prep](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/prepare_t2s_txts.py): `whisperspeech/prepare_t2s_txts.py`
- [Acoustic-model data prep](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/prepare_s2a_atoks.py): `whisperspeech/prepare_s2a_atoks.py`

### Evaluation and metrics

- [Model testing](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/testing.py): `whisperspeech/testing.py`
- [Speech metrics](https://github.com/venuaditya/whisperspeech/blob/main/whisperspeech/extract_metrics.py): `whisperspeech/extract_metrics.py`

### Other components

- **Text-to-speech user**
- **Whisper**
- **EnCodec**
- **Vocos**

## Connections

- Text-to-speech user → TTS pipeline: requests speech
- TTS pipeline → Text-to-semantic model: generates semantic tokens
- Text-to-semantic model → Semantic-to-acoustic model: conditions generation
- Semantic-to-acoustic model → Audio rendering: renders audio
- Audio rendering → Inference utilities: uses utilities (evidence: `whisperspeech/a2wav.py`)
- Semantic tokens → Whisper: transcription to tokens (evidence: `README.md`)
- EnCodec → Semantic-to-acoustic model: tokenizes waveform (evidence: `README.md`)
- Vocos → Audio rendering: synthesizes audio (evidence: `README.md`)
- Text-to-semantic model → Neural building blocks: uses building blocks (evidence: `whisperspeech/t2s_up_wds_mlang_enclm.py`)
- Text-to-semantic model → Language mapping: uses language IDs (evidence: `whisperspeech/t2s_up_wds_mlang_enclm.py`)
- Semantic-to-acoustic model → Neural building blocks: uses building blocks (evidence: `whisperspeech/s2a_delar_mup_wds_mlang.py`)
- Semantic-to-acoustic model → Language mapping: uses language IDs (evidence: `whisperspeech/s2a_delar_mup_wds_mlang.py`)
- Conditioned acoustic model → Neural building blocks: uses building blocks (evidence: `whisperspeech/s2a_delar_mup_wds_mlang_cond.py`)
- Conditioned acoustic model → Language mapping: uses language IDs (evidence: `whisperspeech/s2a_delar_mup_wds_mlang_cond.py`)
- Voice activity detection → Inference utilities: selects compute device (evidence: `whisperspeech/vad.py`)
- Whisper transcription → Voice activity detection: uses VAD (evidence: `whisperspeech/wh_transcribe.py`)
- Whisper transcription → Inference utilities: selects compute device (evidence: `whisperspeech/wh_transcribe.py`)
- Speaker embeddings → Voice activity detection: uses VAD (evidence: `whisperspeech/extract_spk_emb.py`)
- Speaker embeddings → Inference utilities: uses utilities (evidence: `whisperspeech/extract_spk_emb.py`)
- Semantic-token extraction → Semantic tokens: extracts tokens (evidence: `whisperspeech/extract_stoks.py`)
- Semantic-token extraction → VAD segment merging: uses merged segments (evidence: `whisperspeech/extract_stoks.py`)
- Text-model data prep → VAD segment merging: uses merged segments (evidence: `whisperspeech/prepare_t2s_txts.py`)
- Acoustic-model data prep → VAD segment merging: uses merged segments (evidence: `whisperspeech/prepare_s2a_atoks.py`)
- Model training → Neural building blocks: uses utilities (evidence: `whisperspeech/train.py`)
- Distributed training → Model testing: uses testing (evidence: `whisperspeech/train_multi.py`)
- Speech metrics → Semantic tokens: uses token model (evidence: `whisperspeech/extract_metrics.py`)
- Speech metrics → VAD segment merging: uses merged segments (evidence: `whisperspeech/extract_metrics.py`)
- Speech metrics → Inference utilities: uses utilities (evidence: `whisperspeech/extract_metrics.py`)
