How cruellyyy/minepyvideotrans works
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: task Task engine · mainwin Main window · ui Provider forms · translator Translation adapters
Components 24
Entrypoints
Desktop, CLI, and lightweight operational launchers.
- GUI launcher · Starts the desktop application.
sp.py - CLI runner · Headless batch and automation entrypoint.
cli.py - CLI harness · Small operational test runner.
testcli.py - CUDA harness · Environment and GPU validation helper.
testcuda.py
Desktop UI
Qt-based windowing, forms, and reusable controls.
- Main window · Primary window and event wiring.
videotrans/mainwin - Provider forms · Settings screens for engines and features.
videotrans/ui - Function forms · Reusable dialogs and feature panels.
videotrans/winform - UI widgets · Shared controls such as progress, proxy, and subtitle tools.
videotrans/component
Workflow Engine
Task orchestration and pipeline coordination.
- Task engine · Coordinates speech, translation, dubbing, and multi-video flows.
videotrans/task
Media Core
Audio/video preparation and processing helpers.
- Audio prep · Extracts and prepares audio for downstream stages.
videotrans/process/prepare_audio.py - STT helpers · Speech-to-text helper functions.
videotrans/process/stt_fun.py - TTS helpers · Text-to-speech helper functions.
videotrans/process/tts_fun.py - Trim tool · Video trimming helper used by media workflows.
pymovie/trim.py
Provider Adapters
Recognition, translation, and TTS backends.
- ASR adapters · Pluggable speech recognition engines and wrappers.
videotrans/recognition - Translation adapters · Provider adapters for subtitle and text translation.
videotrans/translator - TTS adapters · Provider adapters for voice synthesis and dubbing.
videotrans/tts
Shared Runtime
Configuration, signals, models, and utilities.
- Config & errors · Central configuration, exception handling, and WhisperNet setup.
videotrans/configure - Signals & models · Shared data models and event signal objects.
videotrans/codes/model.py - Utilities · General helpers for FFmpeg, GPU, SRT, roles, and downloads.
videotrans/util
Assets
Prompts, voice catalogs, localization, and bundled media.
- Prompt pack · Prompt templates for translation and recognition behavior.
videotrans/prompts - Voice catalogs · Voice lists and engine metadata used by selection logic.
videotrans/voicejson - Language packs · UI localization resources.
videotrans/language - Styles assets · Qt stylesheet and bundled media assets.
videotrans/styles - FFmpeg bundle · Bundled FFmpeg tooling used for media assembly.
ffmpeg
Connections 24
- 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.