# aifsh/comfyui-xtts architecture

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

- Interactive diagram: https://gitdiagram.com/aifsh/comfyui-xtts
- Repository: https://github.com/aifsh/comfyui-xtts

## Overview

ComfyUI-XTTS adds a ComfyUI node for multilingual XTTS synthesis and voice cloning. The user supplies text and reference audio, optionally with SRT subtitles for multi-speaker output; the node produces audio that can be previewed or saved. The README documents 17-language support and subtitle-based speaker handling. The node implementation is not sampled, so its precise calls and how uploads reach synthesis are uncertain; the graph shows the documented workflow and imports visible in the XTTS model source.

Main entry points: [`TTS/tts/models/xtts.py`](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/models/xtts.py) (XTTS synthesis), [`nodes.py`](https://github.com/aifsh/comfyui-xtts/blob/main/nodes.py) (XTTS node), [`web/js/uploadAudio.js`](https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadAudio.js) (Reference audio upload), [`web/js/uploadSRT.js`](https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadSRT.js) (SRT upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["ComfyUI interface"]
  node_upload_audio["Reference audio upload<br/>[uploadAudio.js]"]
  node_upload_srt["SRT upload<br/>[uploadSRT.js]"]
  node_preview["Audio preview<br/>[previewAudio.js]"]
end

subgraph group_workflow["Synthesis workflow"]
  node_node["XTTS node<br/>[nodes.py]"]
end

subgraph group_model["XTTS model"]
  node_model_xtts["XTTS synthesis<br/>[xtts.py]"]
  node_tokenizer["Text tokenizer<br/>[tokenizer.py]"]
  node_gpt["Autoregressive GPT<br/>[gpt.py]"]
  node_decoder["Audio decoder<br/>[hifigan_decoder.py]"]
  node_managers["Speaker and language managers<br/>[xtts_manager.py]"]
end

node_user(("ComfyUI user"))
node_audio_result["Generated audio"]

node_user -->|"selects audio"| node_upload_audio
node_user -->|"selects subtitles"| node_upload_srt
node_user -->|"provides text and options"| node_node
node_upload_audio -->|"supplies reference"| node_node
node_upload_srt -->|"supplies subtitles"| node_node
node_node -->|"invokes synthesis"| node_model_xtts
node_model_xtts -->|"tokenizes text"| node_tokenizer
node_model_xtts -->|"generates tokens"| node_gpt
node_model_xtts -->|"decodes audio"| node_decoder
node_model_xtts -->|"uses speaker and language data"| node_managers
node_model_xtts -->|"returns generated audio"| node_node
node_node -->|"exposes audio"| node_preview
node_preview -->|"previews or saves"| node_audio_result

click node_upload_audio "https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadAudio.js"
click node_upload_srt "https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadSRT.js"
click node_node "https://github.com/aifsh/comfyui-xtts/blob/main/nodes.py"
click node_model_xtts "https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/models/xtts.py"
click node_tokenizer "https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/tokenizer.py"
click node_gpt "https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/gpt.py"
click node_decoder "https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/hifigan_decoder.py"
click node_managers "https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/xtts_manager.py"
click node_preview "https://github.com/aifsh/comfyui-xtts/blob/main/web/js/previewAudio.js"

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_upload_audio,node_upload_srt,node_preview,node_user toneBlue
class node_node toneAmber
class node_model_xtts,node_tokenizer,node_gpt,node_decoder,node_managers toneMint
class node_audio_result toneIndigo
```

## Components

### ComfyUI interface

- [Reference audio upload](https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadAudio.js): `web/js/uploadAudio.js`
- [SRT upload](https://github.com/aifsh/comfyui-xtts/blob/main/web/js/uploadSRT.js): `web/js/uploadSRT.js`
- [Audio preview](https://github.com/aifsh/comfyui-xtts/blob/main/web/js/previewAudio.js): `web/js/previewAudio.js`

### Synthesis workflow

- [XTTS node](https://github.com/aifsh/comfyui-xtts/blob/main/nodes.py): `nodes.py`

### XTTS model

- [XTTS synthesis](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/models/xtts.py): `TTS/tts/models/xtts.py`
- [Text tokenizer](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/tokenizer.py): `TTS/tts/layers/xtts/tokenizer.py`
- [Autoregressive GPT](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/gpt.py): `TTS/tts/layers/xtts/gpt.py`
- [Audio decoder](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/hifigan_decoder.py): `TTS/tts/layers/xtts/hifigan_decoder.py`
- [Speaker and language managers](https://github.com/aifsh/comfyui-xtts/blob/main/TTS/tts/layers/xtts/xtts_manager.py): `TTS/tts/layers/xtts/xtts_manager.py`

### Other components

- **ComfyUI user**
- **Generated audio**

## Connections

- ComfyUI user → Reference audio upload: selects audio
- ComfyUI user → SRT upload: selects subtitles
- ComfyUI user → XTTS node: provides text and options
- Reference audio upload → XTTS node: supplies reference
- SRT upload → XTTS node: supplies subtitles
- XTTS node → XTTS synthesis: invokes synthesis
- XTTS synthesis → Text tokenizer: tokenizes text
- XTTS synthesis → Autoregressive GPT: generates tokens
- XTTS synthesis → Audio decoder: decodes audio
- XTTS synthesis → Speaker and language managers: uses speaker and language data
- XTTS synthesis → XTTS node: returns generated audio
- XTTS node → Audio preview: exposes audio
- Audio preview → Generated audio: previews or saves
