# brasd99/heygenclone architecture

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

- Interactive diagram: https://gitdiagram.com/brasd99/heygenclone
- Repository: https://github.com/brasd99/heygenclone

## Overview

HeyGenClone translates a video’s speech and produces a dubbed video; it also offers a separate voice-driven lip-sync workflow. The documented translation stages cover scene and face analysis, speech cleanup, transcription and speaker attribution, translation, voice cloning, video lip-sync, face restoration, and audio/video assembly. The graph emphasizes the translation orchestrator and major runtime subsystems. Some stage links are based on README documentation because the relevant engine code was not fully excerpted.

Main entry points: [`core/engine.py`](https://github.com/brasd99/heygenclone/blob/main/core/engine.py) (Translation engine), [`core/scene_preprocessor.py`](https://github.com/brasd99/heygenclone/blob/main/core/scene_preprocessor.py) (Scene and face analysis), [`core/face/lipsync.py`](https://github.com/brasd99/heygenclone/blob/main/core/face/lipsync.py) (Lip-sync rendering), [`translate.py`](https://github.com/brasd99/heygenclone/blob/main/translate.py) (Translation CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_translate_cli["Translation CLI<br/>[translate.py]"]
  node_engine["Translation engine<br/>[engine.py]"]
  node_temp_files["Temporary files<br/>[temp_manager.py]"]
end

subgraph group_analysis["Scene and speech analysis"]
  node_scene["Scene and face analysis"]
  node_face_detector["Face detector<br/>[detector.py]"]
  node_face_store[("Face records")]
  node_dereverb["Speech cleanup<br/>[dereverb.py]"]
  node_asr["Speech recognition<br/>[asr.py]"]
  node_alignment["Word alignment<br/>[alignment.py]"]
  node_diarization["Speaker diarization<br/>[diarize.py]"]
  node_vad["Voice activity detection<br/>[vad.py]"]
  node_subtitle_processing["Subtitle processing"]
end

subgraph group_speech["Translated speech"]
  node_translator["Text translation<br/>[translator.py]"]
  node_language_map["Language mapping<br/>[mapper.py]"]
  node_voice_cloner["Voice cloning<br/>[voice_cloner.py]"]
end

subgraph group_video["Video rendering"]
  node_lipsync["Lip-sync rendering<br/>[lipsync.py]"]
  node_wav2lip["Wav2Lip model<br/>[wav2lip.py]"]
  node_face_restoration["Face restoration<br/>[gfpganer.py]"]
end

node_user(("Video user"))
node_output_video["Dubbed video"]

node_user -->|"provides video"| node_translate_cli
node_translate_cli -->|"starts translation"| node_engine
node_engine -->|"analyzes video"| node_scene
node_scene -->|"detects faces"| node_face_detector
node_scene -->|"stores face records"| node_face_store
node_engine -->|"cleans speech"| node_dereverb
node_engine -->|"transcribes speech"| node_asr
node_asr -->|"uses voice detection"| node_vad
node_engine -->|"aligns transcript"| node_alignment
node_engine -->|"assigns speakers"| node_diarization
node_engine -.->|"processes subtitles"| node_subtitle_processing
node_engine -->|"translates text"| node_translator
node_translator -->|"maps languages"| node_language_map
node_engine -->|"clones voices"| node_voice_cloner
node_engine -->|"renders lip sync"| node_lipsync
node_lipsync -->|"runs model"| node_wav2lip
node_lipsync -->|"restores faces"| node_face_restoration
node_engine -->|"creates temp files"| node_temp_files
node_engine -.->|"assembles output"| node_output_video

click node_translate_cli "https://github.com/brasd99/heygenclone/blob/main/translate.py"
click node_engine "https://github.com/brasd99/heygenclone/blob/main/core/engine.py"
click node_scene "https://github.com/brasd99/heygenclone/blob/main/core/scene_preprocessor.py"
click node_face_detector "https://github.com/brasd99/heygenclone/blob/main/core/face/detector.py"
click node_face_store "https://github.com/brasd99/heygenclone/blob/main/core/scene_preprocessor.py"
click node_dereverb "https://github.com/brasd99/heygenclone/blob/main/core/dereverb.py"
click node_asr "https://github.com/brasd99/heygenclone/blob/main/core/whisperx/asr.py"
click node_alignment "https://github.com/brasd99/heygenclone/blob/main/core/whisperx/alignment.py"
click node_diarization "https://github.com/brasd99/heygenclone/blob/main/core/whisperx/diarize.py"
click node_vad "https://github.com/brasd99/heygenclone/blob/main/core/whisperx/vad.py"
click node_subtitle_processing "https://github.com/brasd99/heygenclone/blob/main/core/whisperx/SubtitlesProcessor.py"
click node_translator "https://github.com/brasd99/heygenclone/blob/main/core/translator.py"
click node_language_map "https://github.com/brasd99/heygenclone/blob/main/core/mapper.py"
click node_voice_cloner "https://github.com/brasd99/heygenclone/blob/main/core/voice_cloner.py"
click node_lipsync "https://github.com/brasd99/heygenclone/blob/main/core/face/lipsync.py"
click node_wav2lip "https://github.com/brasd99/heygenclone/blob/main/core/face/models/wav2lip.py"
click node_face_restoration "https://github.com/brasd99/heygenclone/blob/main/core/gfpganer.py"
click node_temp_files "https://github.com/brasd99/heygenclone/blob/main/core/temp_manager.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_translate_cli,node_engine,node_temp_files,node_user toneBlue
class node_scene,node_face_detector,node_face_store,node_dereverb,node_asr,node_alignment,node_diarization,node_vad,node_subtitle_processing toneAmber
class node_translator,node_language_map,node_voice_cloner toneMint
class node_lipsync,node_wav2lip,node_face_restoration toneRose
class node_output_video toneIndigo
```

## Components

### Entry and orchestration

- [Translation CLI](https://github.com/brasd99/heygenclone/blob/main/translate.py): `translate.py`
- [Translation engine](https://github.com/brasd99/heygenclone/blob/main/core/engine.py): `core/engine.py`
- [Temporary files](https://github.com/brasd99/heygenclone/blob/main/core/temp_manager.py): `core/temp_manager.py`

### Scene and speech analysis

- [Scene and face analysis](https://github.com/brasd99/heygenclone/blob/main/core/scene_preprocessor.py): `core/scene_preprocessor.py`
- [Face detector](https://github.com/brasd99/heygenclone/blob/main/core/face/detector.py): `core/face/detector.py`
- [Face records](https://github.com/brasd99/heygenclone/blob/main/core/scene_preprocessor.py): `core/scene_preprocessor.py`
- [Speech cleanup](https://github.com/brasd99/heygenclone/blob/main/core/dereverb.py): `core/dereverb.py`
- [Speech recognition](https://github.com/brasd99/heygenclone/blob/main/core/whisperx/asr.py): `core/whisperx/asr.py`
- [Word alignment](https://github.com/brasd99/heygenclone/blob/main/core/whisperx/alignment.py): `core/whisperx/alignment.py`
- [Speaker diarization](https://github.com/brasd99/heygenclone/blob/main/core/whisperx/diarize.py): `core/whisperx/diarize.py`
- [Voice activity detection](https://github.com/brasd99/heygenclone/blob/main/core/whisperx/vad.py): `core/whisperx/vad.py`
- [Subtitle processing](https://github.com/brasd99/heygenclone/blob/main/core/whisperx/SubtitlesProcessor.py): `core/whisperx/SubtitlesProcessor.py`

### Translated speech

- [Text translation](https://github.com/brasd99/heygenclone/blob/main/core/translator.py): `core/translator.py`
- [Language mapping](https://github.com/brasd99/heygenclone/blob/main/core/mapper.py): `core/mapper.py`
- [Voice cloning](https://github.com/brasd99/heygenclone/blob/main/core/voice_cloner.py): `core/voice_cloner.py`

### Video rendering

- [Lip-sync rendering](https://github.com/brasd99/heygenclone/blob/main/core/face/lipsync.py): `core/face/lipsync.py`
- [Wav2Lip model](https://github.com/brasd99/heygenclone/blob/main/core/face/models/wav2lip.py): `core/face/models/wav2lip.py`
- [Face restoration](https://github.com/brasd99/heygenclone/blob/main/core/gfpganer.py): `core/gfpganer.py`

### Other components

- **Video user**
- **Dubbed video**

## Connections

- Video user → Translation CLI: provides video (evidence: `README.md`)
- Translation CLI → Translation engine: starts translation (evidence: `translate.py`)
- Translation engine → Scene and face analysis: analyzes video (evidence: `core/engine.py`)
- Scene and face analysis → Face detector: detects faces (evidence: `core/scene_preprocessor.py`)
- Scene and face analysis → Face records: stores face records (evidence: `core/scene_preprocessor.py`)
- Translation engine → Speech cleanup: cleans speech (evidence: `core/engine.py`)
- Translation engine → Speech recognition: transcribes speech (evidence: `core/engine.py`)
- Speech recognition → Voice activity detection: uses voice detection (evidence: `core/whisperx/asr.py`)
- Translation engine → Word alignment: aligns transcript (evidence: `core/engine.py`)
- Translation engine → Speaker diarization: assigns speakers (evidence: `core/engine.py`)
- Translation engine → Subtitle processing: processes subtitles (evidence: `README.md`)
- Translation engine → Text translation: translates text (evidence: `core/engine.py`)
- Text translation → Language mapping: maps languages (evidence: `core/translator.py`)
- Translation engine → Voice cloning: clones voices (evidence: `core/engine.py`)
- Translation engine → Lip-sync rendering: renders lip sync (evidence: `core/engine.py`)
- Lip-sync rendering → Wav2Lip model: runs model (evidence: `core/face/lipsync.py`)
- Lip-sync rendering → Face restoration: restores faces (evidence: `core/face/lipsync.py`)
- Translation engine → Temporary files: creates temp files (evidence: `core/engine.py`)
- Translation engine → Dubbed video: assembles output (evidence: `README.md`)
