# cruellyyy/minepyvideotrans architecture

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

- Interactive diagram: https://gitdiagram.com/cruellyyy/minepyvideotrans
- Repository: https://github.com/cruellyyy/minepyvideotrans

## Overview

1. **Repository purpose and shape**  
   This is a desktop-first Python application for media translation: video/audio ingestion, speech recognition, subtitle translation, text-to-speech dubbing, and final audio-video reassembly. The architecture is a layered pipeline with both a **GUI** and a **CLI** sharing the same core task engine.

2. **Primary entry points**  
   `sp.py` is the GUI launcher, and `cli.py` is the headless batch/automation entry point. `testcli.py` and `testcuda.py` are small operational/test harnesses. The repo also includes CI in `.github/workflows/main.yml`.

3. **User interface layer**  
   The `videotrans/ui`, `videotrans/winform`, and `videotrans/mainwin` packages hold the PySide6-based desktop UI. `mainwin` appears to be the main application window and event wiring, while `ui`/`winform` contain per-provider or per-feature settings screens and forms. `videotrans/component` provides reusable UI widgets and controls such as progress bars, proxy/thread settings, subtitle length tools, and role/recognition configuration panels.

4. **Workflow orchestration layer**  
   `videotrans/task` is the central coordination layer. It contains task types for speech-to-text, translation, dubbing, multi-video handling, and “single-item” flows. This layer is likely where the app sequences stages, manages progress, handles cancellation/retry, and bridges GUI signals to the processing pipeline.

5. **Core media processing**  
   `videotrans/process` handles the lower-level media operations that feed the pipeline: audio preparation, STT helper functions, TTS helper functions, VAD, and signal objects used during processing. The repo also includes `pymovie/trim.py` and bundled `ffmpeg` assets, which indicates media cutting, probing, muxing, and format conversion are foundational dependencies.

6. **Speech recognition subsystem**  
   `videotrans/recognition` is a pluggable ASR backend family. It includes local engines like Whisper/WhisperX/FunASR/Parakeet/Qwen local, and remote services such as Google, Deepgram, Gemini, ByteDance, Alibaba, and others. `videotrans/recognition/_base.py` and `_overall.py` suggest a shared abstraction and a common orchestration wrapper around multiple engines.

7. **Translation subsystem**  
   `videotrans/translator` is another adapter layer with many providers: DeepSeek, ChatGPT, Gemini, Azure, Google, Microsoft, Baidu, Tencent, Ollama/local LLMs, MiniMax, ZhipuAI, and more. The `videotrans/prompts` directory stores provider-specific prompt templates for subtitle and text translation, so translation behavior is partly policy-driven rather than hardcoded.

8. **Text-to-speech / dubbing subsystem**  
   `videotrans/tts` contains TTS adapters for Edge TTS, Azure, OpenAI, ElevenLabs, Google Cloud, MiniMax, F5-TTS, CosyVoice, GPT-SoVITS, Piper, and other engines. `videotrans/voicejson` provides voice catalogs and metadata used by the UI and TTS selection logic. This subsystem is the main output-side boundary that turns translated text into per-role voice tracks.

9. **Shared configuration, state, and error handling**  
   `videotrans/configure` centralizes application config, exception handling, and WhisperNet setup. `videotrans/codes/model.py` likely defines shared enums or data models. The presence of signal objects in `task/signelobj.py` and `process/signelobj.py` indicates the app relies on event-driven state propagation between background jobs and the UI.

10. **Assets and localization**  
   `videotrans/language` contains language packs (`en.json`, `zh.json`) for UI localization. `videotrans/styles` contains the Qt stylesheet and bundled media assets. `docs` and `README*` provide user-facing setup and operational guidance, while `models/` is reserved for downloadable or local model artifacts.

11. **External service boundary**  
   A major architectural boundary is between **local/offline execution** and **cloud/API-backed providers**. The adapter packages for recognition, translation, and TTS isolate vendor-specific protocols from the rest of the app, so the higher-level workflow can treat engines uniformly even though some run locally and others call external APIs.

12. **End-to-end data flow**  
   The typical flow is: input video/audio enters the task layer, audio is extracted/prepared, ASR produces timestamps/subtitles, subtitles are translated, TTS generates voice tracks, and FFmpeg-based tooling merges the final synchronized result. Optional branches include speaker diarization, manual editing/review, subtitle merging, vocal separation, and utility transformations.

13. **Operational concerns**  
   The app is cross-platform but strongly media-tool dependent: Python 3.10+, PySide6, FFmpeg, and optional CUDA-enabled PyTorch/ASR stacks. That means the architecture includes both application logic and environment/tooling dependencies, especially for GPU acceleration and bundled model/runtime support.

Main entry points: [`videotrans/task`](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/task) (Task engine), [`videotrans/mainwin`](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/mainwin) (Main window), [`videotrans/ui`](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/ui) (Provider forms), [`videotrans/translator`](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/translator) (Translation adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entrypoints"]
  node_sp_py["GUI launcher<br/>entrypoint<br/>[sp.py]"]
  node_cli_py["CLI runner<br/>entrypoint<br/>[cli.py]"]
  node_testcli_py["CLI harness<br/>ops<br/>[testcli.py]"]
  node_testcuda_py["CUDA harness<br/>ops<br/>[testcuda.py]"]
end

subgraph group_ui["Desktop UI"]
  node_mainwin["Main window<br/>ui-shell"]
  node_ui_forms["Provider forms<br/>ui-screens"]
  node_winforms["Function forms<br/>ui-forms"]
  node_widgets["UI widgets<br/>ui-controls"]
end

subgraph group_engine["Workflow Engine"]
  node_task_engine{{"Task engine<br/>orchestrator"}}
end

subgraph group_media["Media Core"]
  node_prepare_audio["Audio prep<br/>media-prep<br/>[prepare_audio.py]"]
  node_stt_fun["STT helpers<br/>stt-core<br/>[stt_fun.py]"]
  node_tts_fun["TTS helpers<br/>tts-core<br/>[tts_fun.py]"]
  node_pymovie_trim["Trim tool<br/>media-tool<br/>[trim.py]"]
end

subgraph group_adapters["Provider Adapters"]
  node_recognition[("ASR adapters<br/>backend-family")]
  node_translator[("Translation adapters<br/>backend-family")]
  node_tts[("TTS adapters<br/>backend-family")]
end

subgraph group_shared["Shared Runtime"]
  node_config["Config & errors<br/>runtime-config"]
  node_signals_models["Signals & models<br/>shared-state<br/>[model.py]"]
  node_utilities["Utilities<br/>helpers"]
end

subgraph group_assets["Assets"]
  node_prompts["Prompt pack<br/>policy-text"]
  node_voices["Voice catalogs<br/>metadata"]
  node_language["Language packs<br/>localization"]
  node_styles["Styles assets<br/>ui-assets"]
  node_ffmpeg_assets[("FFmpeg bundle<br/>runtime-binary")]
end

node_sp_py -->|"opens"| node_mainwin
node_cli_py -->|"runs"| node_task_engine
node_mainwin -->|"uses"| node_ui_forms
node_mainwin -->|"uses"| node_winforms
node_mainwin -->|"shares"| node_widgets
node_ui_forms -.->|"configures"| node_recognition
node_ui_forms -.->|"configures"| node_translator
node_ui_forms -.->|"configures"| node_tts
node_task_engine -->|"orchestrates"| node_prepare_audio
node_task_engine -->|"orchestrates"| node_stt_fun
node_task_engine -->|"calls"| node_translator
node_task_engine -->|"calls"| node_tts
node_task_engine -->|"assembles"| node_ffmpeg_assets
node_task_engine -.->|"updates"| node_signals_models
node_recognition -.->|"reads"| node_config
node_translator -.->|"loads"| node_prompts
node_tts -.->|"loads"| node_voices
node_task_engine -->|"uses"| node_utilities
node_utilities -.->|"wraps"| node_ffmpeg_assets
node_pymovie_trim -.->|"depends on"| node_ffmpeg_assets
node_sp_py -.->|"localizes"| node_language
node_mainwin -.->|"skins"| node_styles
node_testcuda_py -.->|"checks"| node_config
node_testcli_py -.->|"smokes"| node_task_engine

click node_sp_py "https://github.com/cruellyyy/minepyvideotrans/blob/main/sp.py"
click node_cli_py "https://github.com/cruellyyy/minepyvideotrans/blob/main/cli.py"
click node_testcli_py "https://github.com/cruellyyy/minepyvideotrans/blob/main/testcli.py"
click node_testcuda_py "https://github.com/cruellyyy/minepyvideotrans/blob/main/testcuda.py"
click node_mainwin "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/mainwin"
click node_ui_forms "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/ui"
click node_winforms "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/winform"
click node_widgets "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/component"
click node_task_engine "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/task"
click node_prepare_audio "https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/prepare_audio.py"
click node_stt_fun "https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/stt_fun.py"
click node_tts_fun "https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/tts_fun.py"
click node_recognition "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/recognition"
click node_translator "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/translator"
click node_tts "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/tts"
click node_config "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/configure"
click node_signals_models "https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/codes/model.py"
click node_utilities "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/util"
click node_prompts "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/prompts"
click node_voices "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/voicejson"
click node_language "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/language"
click node_styles "https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/styles"
click node_ffmpeg_assets "https://github.com/cruellyyy/minepyvideotrans/tree/main/ffmpeg"
click node_pymovie_trim "https://github.com/cruellyyy/minepyvideotrans/blob/main/pymovie/trim.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_sp_py,node_cli_py,node_testcli_py,node_testcuda_py,node_prompts,node_voices,node_language,node_styles,node_ffmpeg_assets toneBlue
class node_mainwin,node_ui_forms,node_winforms,node_widgets toneAmber
class node_task_engine toneMint
class node_prepare_audio,node_stt_fun,node_tts_fun,node_pymovie_trim toneRose
class node_recognition,node_translator,node_tts toneIndigo
class node_config,node_signals_models,node_utilities toneTeal
```

## Components

### Entrypoints

Desktop, CLI, and lightweight operational launchers.

- [GUI launcher](https://github.com/cruellyyy/minepyvideotrans/blob/main/sp.py): entrypoint · Starts the desktop application. · `sp.py`
- [CLI runner](https://github.com/cruellyyy/minepyvideotrans/blob/main/cli.py): entrypoint · Headless batch and automation entrypoint. · `cli.py`
- [CLI harness](https://github.com/cruellyyy/minepyvideotrans/blob/main/testcli.py): ops · Small operational test runner. · `testcli.py`
- [CUDA harness](https://github.com/cruellyyy/minepyvideotrans/blob/main/testcuda.py): ops · Environment and GPU validation helper. · `testcuda.py`

### Desktop UI

Qt-based windowing, forms, and reusable controls.

- [Main window](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/mainwin): ui-shell · Primary window and event wiring. · `videotrans/mainwin`
- [Provider forms](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/ui): ui-screens · Settings screens for engines and features. · `videotrans/ui`
- [Function forms](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/winform): ui-forms · Reusable dialogs and feature panels. · `videotrans/winform`
- [UI widgets](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/component): ui-controls · Shared controls such as progress, proxy, and subtitle tools. · `videotrans/component`

### Workflow Engine

Task orchestration and pipeline coordination.

- [Task engine](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/task): orchestrator · Coordinates speech, translation, dubbing, and multi-video flows. · `videotrans/task`

### Media Core

Audio/video preparation and processing helpers.

- [Audio prep](https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/prepare_audio.py): media-prep · Extracts and prepares audio for downstream stages. · `videotrans/process/prepare_audio.py`
- [STT helpers](https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/stt_fun.py): stt-core · Speech-to-text helper functions. · `videotrans/process/stt_fun.py`
- [TTS helpers](https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/process/tts_fun.py): tts-core · Text-to-speech helper functions. · `videotrans/process/tts_fun.py`
- [Trim tool](https://github.com/cruellyyy/minepyvideotrans/blob/main/pymovie/trim.py): media-tool · Video trimming helper used by media workflows. · `pymovie/trim.py`

### Provider Adapters

Recognition, translation, and TTS backends.

- [ASR adapters](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/recognition): backend-family · Pluggable speech recognition engines and wrappers. · `videotrans/recognition`
- [Translation adapters](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/translator): backend-family · Provider adapters for subtitle and text translation. · `videotrans/translator`
- [TTS adapters](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/tts): backend-family · Provider adapters for voice synthesis and dubbing. · `videotrans/tts`

### Shared Runtime

Configuration, signals, models, and utilities.

- [Config & errors](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/configure): runtime-config · Central configuration, exception handling, and WhisperNet setup. · `videotrans/configure`
- [Signals & models](https://github.com/cruellyyy/minepyvideotrans/blob/main/videotrans/codes/model.py): shared-state · Shared data models and event signal objects. · `videotrans/codes/model.py`
- [Utilities](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/util): helpers · General helpers for FFmpeg, GPU, SRT, roles, and downloads. · `videotrans/util`

### Assets

Prompts, voice catalogs, localization, and bundled media.

- [Prompt pack](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/prompts): policy-text · Prompt templates for translation and recognition behavior. · `videotrans/prompts`
- [Voice catalogs](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/voicejson): metadata · Voice lists and engine metadata used by selection logic. · `videotrans/voicejson`
- [Language packs](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/language): localization · UI localization resources. · `videotrans/language`
- [Styles assets](https://github.com/cruellyyy/minepyvideotrans/tree/main/videotrans/styles): ui-assets · Qt stylesheet and bundled media assets. · `videotrans/styles`
- [FFmpeg bundle](https://github.com/cruellyyy/minepyvideotrans/tree/main/ffmpeg): runtime-binary · Bundled FFmpeg tooling used for media assembly. · `ffmpeg`

## Connections

- GUI launcher → Main window: opens · GUI launcher creates the main desktop window.
- CLI runner → Task engine: runs · CLI enters the shared task pipeline.
- Main window → Provider forms: uses · Main window wires provider and feature screens.
- Main window → Function forms: uses · Main window opens task-specific dialogs.
- Main window → UI widgets: shares · UI relies on common controls and utility widgets.
- Provider forms → ASR adapters: configures · UI screens expose recognition provider settings.
- Provider forms → Translation adapters: configures · UI screens expose translation provider settings.
- Provider forms → TTS adapters: configures · UI screens expose TTS provider settings.
- Task engine → Audio prep: orchestrates · Tasks begin with audio extraction and preparation.
- Task engine → STT helpers: orchestrates · Tasks invoke speech-to-text helpers.
- Task engine → Translation adapters: calls · Workflow sends subtitles/text to translation adapters.
- Task engine → TTS adapters: calls · Workflow sends translated text to TTS adapters.
- Task engine → FFmpeg bundle: assembles · Final media reassembly depends on FFmpeg tooling.
- Task engine → Signals & models: updates · Progress and job state flow through shared signals and models.
- ASR adapters → Config & errors: reads · Backends use shared configuration and exception handling.
- Translation adapters → Prompt pack: loads · Adapters use prompt templates for provider behavior.
- TTS adapters → Voice catalogs: loads · Adapters use voice catalogs and metadata.
- Task engine → Utilities: uses · Workflow depends on helper modules for media and environment tasks.
- Utilities → FFmpeg bundle: wraps · Helpers wrap FFmpeg-based operations.
- Trim tool → FFmpeg bundle: depends on · Trim utility relies on bundled FFmpeg capabilities.
- GUI launcher → Language packs: localizes · Desktop UI loads translated labels and messages.
- Main window → Styles assets: skins · Main window applies bundled Qt styling and assets.
- CUDA harness → Config & errors: checks · GPU harness validates runtime readiness.
- CLI harness → Task engine: smokes · CLI harness exercises the shared workflow.
