A modular, production-ready Python pipeline that takes a Kannada video and produces a Hindi-dubbed version with voice cloning, lip synchronization, and face restoration — all using free, open-source tools.
Built for the Supernan AI Automation Intern Challenge "The Golden 15 Seconds" — 15 seconds of perfection.
dub_video.py ← Main orchestrator with CLI
│
├── modules/
│ ├── video_utils.py ← FFmpeg-based video/audio I/O
│ ├── transcription.py ← Whisper speech-to-text (Kannada)
│ ├── translation.py ← IndicTrans2 / Google Translate (Kannada→Hindi)
│ ├── tts.py ← XTTS v2 voice cloning
│ ├── alignment.py ← Audio duration matching
│ ├── lipsync.py ← Wav2Lip lip synchronization
│ └── enhancement.py ← GFPGAN face restoration
│
├── setup.py ← Automated environment setup
├── requirements.txt ← Python dependencies
├── AI_Video_Dubber.ipynb ← Google Colab notebook (one-click)
└── outputs/ ← Pipeline outputs (auto-created)
Input Video (full)
↓
┌─────────────────────┐
│ 1. Extract 15s clip │ ← FFmpeg (frame-accurate re-encode)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 2. Extract audio │ ← FFmpeg → 16kHz mono WAV
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 3. Transcribe │ ← OpenAI Whisper (Kannada, word timestamps)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 4. Translate to │ ← IndicTrans2 (Kannada→Hindi, context-aware)
│ Hindi │ or Google Translate (fallback)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 5. Voice cloning │ ← Coqui XTTS v2 (speaker matching)
│ │ or Edge TTS (no-GPU fallback)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 6. Audio alignment │ ← librosa time-stretch + silence trim
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 7. Lip sync │ ← Wav2Lip (GAN model)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 8. Face enhancement │ ← GFPGAN v1.4 (face restoration)
└─────────┬───────────┘
↓
Final Dubbed Video
AI_Video_Dubber.ipynb in Google Colab# Clone repository
git clone https://github.com/YOUR_USERNAME/AI-video-dubber.git
cd AI-video-dubber
# Run automated setup
python setup.py
# Verify installation
python setup.py --check
# Run the pipeline
python dub_video.py --input video.mp4 --start 15 --end 30
| Requirement | Minimum | Recommended |
|---|---|---|
| Python | 3.10+ | 3.10 |
| GPU VRAM | 4 GB | 8 GB+ |
| RAM | 8 GB | 16 GB |
| FFmpeg | Any | 5.0+ |
| Disk Space | 10 GB | 20 GB |
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y ffmpeg
# macOS
brew install ffmpeg
# Windows (via Chocolatey)
choco install ffmpeg
# Google Colab (pre-installed)
pip install -r requirements.txt
python setup.py --setup-wav2lip
Then manually download wav2lip_gan.pth:
Wav2Lip/checkpoints/wav2lip_gan.pthpython setup.py --check
# Process the challenge segment (0:15 - 0:30)
python dub_video.py --input supernan_training.mp4 --start 15 --end 30
# Use IndicTrans2 for better translation quality
python dub_video.py --input video.mp4 --translation indictrans2
# Use Edge TTS (no GPU needed for TTS stage)
python dub_video.py --input video.mp4 --tts edge
# Adjust speech rate for better lip-sync
python dub_video.py --input video.mp4 --speech-rate 1.1
# Skip heavy stages for quick testing
python dub_video.py --input video.mp4 --skip-lipsync --skip-enhancement
# Use smaller Whisper model for faster transcription
python dub_video.py --input video.mp4 --whisper-model base
# Lower Wav2Lip batch size for less VRAM usage
python dub_video.py --input video.mp4 --wav2lip-batch-size 4
python dub_video.py --help
Arguments:
--input, -i Path to input video (required)
--start, -s Start time in seconds (default: 15)
--end, -e End time in seconds (default: 30)
--output-dir, -o Output directory (default: outputs/)
--whisper-model tiny|base|small|medium|large (default: small)
--translation indictrans2|google|seamless (default: google)
--tts xtts|edge (default: xtts)
--speech-rate Speed multiplier (default: 1.05)
--enhancement gfpgan|codeformer (default: gfpgan)
--skip-enhancement Skip face restoration
--skip-lipsync Skip lip synchronization
--wav2lip-dir Wav2Lip repo path (default: Wav2Lip/)
--wav2lip-batch-size Frames per batch (default: 16)
After running the pipeline, outputs/ will contain:
outputs/
├── 01_clip.mp4 ← Extracted 15-second clip
├── 02_audio.wav ← Original Kannada audio
├── 03_transcription.json ← Whisper transcription (Kannada) + timestamps
├── 04_translation.json ← Hindi translation + segments
├── 05_hindi_raw.wav ← Generated Hindi speech
├── 06_hindi_aligned.wav ← Duration-matched Hindi audio
├── 07_lipsynced.mp4 ← Wav2Lip output
├── 08_enhanced.mp4 ← GFPGAN enhanced output
├── final_dubbed.mp4 ← ✅ Final result
├── pipeline_config.json ← Run configuration
└── logs/
└── pipeline_*.log ← Detailed execution log
| Component | Tool | Cost |
|---|---|---|
| Transcription | Whisper (local) | ₹0 |
| Translation | Google Translate / IndicTrans2 | ₹0 |
| Voice Cloning | Coqui XTTS v2 | ₹0 |
| Lip Sync | Wav2Lip | ₹0 |
| Face Enhancement | GFPGAN | ₹0 |
| Compute | Google Colab Free | ₹0 |
| Total | ₹0 |
| GPU | Cost/hr | Processing Time/min | Cost/min of video |
|---|---|---|---|
| Colab Free (T4) | $0.00 | ~8 min | $0.00 |
| AWS g4dn.xlarge (T4) | $0.53 | ~8 min | $0.07 |
| AWS g5.xlarge (A10G) | $1.01 | ~4 min | $0.07 |
| Lambda A10 | $0.75 | ~4 min | $0.05 |
| GPU Tier | Estimated Cost | Time Required |
|---|---|---|
| A10G (single) | ~$2,100 | ~2,000 hrs |
| A10G (10x parallel) | ~$2,100 | ~200 hrs |
| A10G (50x parallel) | ~$2,100 | ~40 hrs ✅ |
To process 500 hours of video overnight (the interview question):
# Split video at silence boundaries / shot changes
# Each segment is independently processable
from scenedetect import detect, ContentDetector
scenes = detect(video_path, ContentDetector())
# Use multiprocessing or distributed compute
# Each scene → separate GPU worker
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(max_workers=num_gpus) as executor:
futures = [executor.submit(process_segment, seg) for seg in segments]
┌──────────────┐
│ Job Queue │ (Redis / SQS)
│ (30K clips) │
└──────┬───────┘
│
┌────────────────┼────────────────┐
↓ ↓ ↓
┌───────────┐ ┌───────────┐ ┌───────────┐
│ GPU Pod 1 │ │ GPU Pod 2 │ │ GPU Pod N │
│ (A10G) │ │ (A10G) │ │ (A10G) │
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
↓ ↓ ↓
┌───────────────────────────────────────────────┐
│ Object Storage (S3) │
│ (source + processed videos) │
└───────────────────────────────────────────────┘
| Decision | Why |
|---|---|
| Whisper small (not base) | Best accuracy/VRAM trade-off for free Colab T4. Whisper supports Kannada transcription. |
| IndicTrans2 (not Google) | Context-aware Kannada→Hindi > literal translation. A nanny would understand it. |
| XTTS v2 (not ElevenLabs) | Free, local, supports Hindi, voice cloning, fits on T4 |
| Audio alignment module | The single biggest quality improvement — syncs lips to speech perfectly |
| GFPGAN post-processing | Wav2Lip blurs the face; GFPGAN restores it to near-original quality |
| Speech rate 1.05x | Hindi output may differ in length from Kannada; slight speedup keeps sync tight |
| Google Translate fallback | IndicTrans2 needs ~4GB VRAM; having a zero-GPU Kannada→Hindi fallback shows resourcefulness |
| Edge TTS fallback | Not everyone has GPU; edge-tts runs anywhere and still sounds professional |
| Package | Version | Purpose |
|---|---|---|
| openai-whisper | ≥20231117 | Speech recognition |
| TTS (Coqui) | ≥0.22.0 | Voice cloning (XTTS v2) |
| deep-translator | ≥1.11.4 | Google Translate fallback |
| IndicTransToolkit | latest | IndicTrans2 translation |
| gfpgan | ≥1.3.8 | Face restoration |
| librosa | ≥0.10.0 | Audio processing/alignment |
| opencv-python | ≥4.8.0 | Video frame processing |
| torch | ≥2.0.0 | ML framework |
| edge-tts | ≥6.1.9 | TTS fallback (no GPU) |
| FFmpeg | ≥5.0 | Video/audio I/O |
MIT License — see LICENSE for details.
21 commits
Python
85.0%
Jupyter Notebook
15.0%
A modular, production-ready Python pipeline that takes a Kannada video and produces a Hindi-dubbed version with voice cloning, lip synchronization, and face restoration — all using free, open-source tools.
Built for the Supernan AI Automation Intern Challenge "The Golden 15 Seconds" — 15 seconds of perfection.
dub_video.py ← Main orchestrator with CLI
│
├── modules/
│ ├── video_utils.py ← FFmpeg-based video/audio I/O
│ ├── transcription.py ← Whisper speech-to-text (Kannada)
│ ├── translation.py ← IndicTrans2 / Google Translate (Kannada→Hindi)
│ ├── tts.py ← XTTS v2 voice cloning
│ ├── alignment.py ← Audio duration matching
│ ├── lipsync.py ← Wav2Lip lip synchronization
│ └── enhancement.py ← GFPGAN face restoration
│
├── setup.py ← Automated environment setup
├── requirements.txt ← Python dependencies
├── AI_Video_Dubber.ipynb ← Google Colab notebook (one-click)
└── outputs/ ← Pipeline outputs (auto-created)
Input Video (full)
↓
┌─────────────────────┐
│ 1. Extract 15s clip │ ← FFmpeg (frame-accurate re-encode)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 2. Extract audio │ ← FFmpeg → 16kHz mono WAV
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 3. Transcribe │ ← OpenAI Whisper (Kannada, word timestamps)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 4. Translate to │ ← IndicTrans2 (Kannada→Hindi, context-aware)
│ Hindi │ or Google Translate (fallback)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 5. Voice cloning │ ← Coqui XTTS v2 (speaker matching)
│ │ or Edge TTS (no-GPU fallback)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 6. Audio alignment │ ← librosa time-stretch + silence trim
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 7. Lip sync │ ← Wav2Lip (GAN model)
└─────────┬───────────┘
↓
┌─────────────────────┐
│ 8. Face enhancement │ ← GFPGAN v1.4 (face restoration)
└─────────┬───────────┘
↓
Final Dubbed Video
AI_Video_Dubber.ipynb in Google Colab# Clone repository
git clone https://github.com/YOUR_USERNAME/AI-video-dubber.git
cd AI-video-dubber
# Run automated setup
python setup.py
# Verify installation
python setup.py --check
# Run the pipeline
python dub_video.py --input video.mp4 --start 15 --end 30
| Requirement | Minimum | Recommended |
|---|---|---|
| Python | 3.10+ | 3.10 |
| GPU VRAM | 4 GB | 8 GB+ |
| RAM | 8 GB | 16 GB |
| FFmpeg | Any | 5.0+ |
| Disk Space | 10 GB | 20 GB |
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y ffmpeg
# macOS
brew install ffmpeg
# Windows (via Chocolatey)
choco install ffmpeg
# Google Colab (pre-installed)
pip install -r requirements.txt
python setup.py --setup-wav2lip
Then manually download wav2lip_gan.pth:
Wav2Lip/checkpoints/wav2lip_gan.pthpython setup.py --check
# Process the challenge segment (0:15 - 0:30)
python dub_video.py --input supernan_training.mp4 --start 15 --end 30
# Use IndicTrans2 for better translation quality
python dub_video.py --input video.mp4 --translation indictrans2
# Use Edge TTS (no GPU needed for TTS stage)
python dub_video.py --input video.mp4 --tts edge
# Adjust speech rate for better lip-sync
python dub_video.py --input video.mp4 --speech-rate 1.1
# Skip heavy stages for quick testing
python dub_video.py --input video.mp4 --skip-lipsync --skip-enhancement
# Use smaller Whisper model for faster transcription
python dub_video.py --input video.mp4 --whisper-model base
# Lower Wav2Lip batch size for less VRAM usage
python dub_video.py --input video.mp4 --wav2lip-batch-size 4
python dub_video.py --help
Arguments:
--input, -i Path to input video (required)
--start, -s Start time in seconds (default: 15)
--end, -e End time in seconds (default: 30)
--output-dir, -o Output directory (default: outputs/)
--whisper-model tiny|base|small|medium|large (default: small)
--translation indictrans2|google|seamless (default: google)
--tts xtts|edge (default: xtts)
--speech-rate Speed multiplier (default: 1.05)
--enhancement gfpgan|codeformer (default: gfpgan)
--skip-enhancement Skip face restoration
--skip-lipsync Skip lip synchronization
--wav2lip-dir Wav2Lip repo path (default: Wav2Lip/)
--wav2lip-batch-size Frames per batch (default: 16)
After running the pipeline, outputs/ will contain:
outputs/
├── 01_clip.mp4 ← Extracted 15-second clip
├── 02_audio.wav ← Original Kannada audio
├── 03_transcription.json ← Whisper transcription (Kannada) + timestamps
├── 04_translation.json ← Hindi translation + segments
├── 05_hindi_raw.wav ← Generated Hindi speech
├── 06_hindi_aligned.wav ← Duration-matched Hindi audio
├── 07_lipsynced.mp4 ← Wav2Lip output
├── 08_enhanced.mp4 ← GFPGAN enhanced output
├── final_dubbed.mp4 ← ✅ Final result
├── pipeline_config.json ← Run configuration
└── logs/
└── pipeline_*.log ← Detailed execution log
| Component | Tool | Cost |
|---|---|---|
| Transcription | Whisper (local) | ₹0 |
| Translation | Google Translate / IndicTrans2 | ₹0 |
| Voice Cloning | Coqui XTTS v2 | ₹0 |
| Lip Sync | Wav2Lip | ₹0 |
| Face Enhancement | GFPGAN | ₹0 |
| Compute | Google Colab Free | ₹0 |
| Total | ₹0 |
| GPU | Cost/hr | Processing Time/min | Cost/min of video |
|---|---|---|---|
| Colab Free (T4) | $0.00 | ~8 min | $0.00 |
| AWS g4dn.xlarge (T4) | $0.53 | ~8 min | $0.07 |
| AWS g5.xlarge (A10G) | $1.01 | ~4 min | $0.07 |
| Lambda A10 | $0.75 | ~4 min | $0.05 |
| GPU Tier | Estimated Cost | Time Required |
|---|---|---|
| A10G (single) | ~$2,100 | ~2,000 hrs |
| A10G (10x parallel) | ~$2,100 | ~200 hrs |
| A10G (50x parallel) | ~$2,100 | ~40 hrs ✅ |
To process 500 hours of video overnight (the interview question):
# Split video at silence boundaries / shot changes
# Each segment is independently processable
from scenedetect import detect, ContentDetector
scenes = detect(video_path, ContentDetector())
# Use multiprocessing or distributed compute
# Each scene → separate GPU worker
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(max_workers=num_gpus) as executor:
futures = [executor.submit(process_segment, seg) for seg in segments]
┌──────────────┐
│ Job Queue │ (Redis / SQS)
│ (30K clips) │
└──────┬───────┘
│
┌────────────────┼────────────────┐
↓ ↓ ↓
┌───────────┐ ┌───────────┐ ┌───────────┐
│ GPU Pod 1 │ │ GPU Pod 2 │ │ GPU Pod N │
│ (A10G) │ │ (A10G) │ │ (A10G) │
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
↓ ↓ ↓
┌───────────────────────────────────────────────┐
│ Object Storage (S3) │
│ (source + processed videos) │
└───────────────────────────────────────────────┘
| Decision | Why |
|---|---|
| Whisper small (not base) | Best accuracy/VRAM trade-off for free Colab T4. Whisper supports Kannada transcription. |
| IndicTrans2 (not Google) | Context-aware Kannada→Hindi > literal translation. A nanny would understand it. |
| XTTS v2 (not ElevenLabs) | Free, local, supports Hindi, voice cloning, fits on T4 |
| Audio alignment module | The single biggest quality improvement — syncs lips to speech perfectly |
| GFPGAN post-processing | Wav2Lip blurs the face; GFPGAN restores it to near-original quality |
| Speech rate 1.05x | Hindi output may differ in length from Kannada; slight speedup keeps sync tight |
| Google Translate fallback | IndicTrans2 needs ~4GB VRAM; having a zero-GPU Kannada→Hindi fallback shows resourcefulness |
| Edge TTS fallback | Not everyone has GPU; edge-tts runs anywhere and still sounds professional |
| Package | Version | Purpose |
|---|---|---|
| openai-whisper | ≥20231117 | Speech recognition |
| TTS (Coqui) | ≥0.22.0 | Voice cloning (XTTS v2) |
| deep-translator | ≥1.11.4 | Google Translate fallback |
| IndicTransToolkit | latest | IndicTrans2 translation |
| gfpgan | ≥1.3.8 | Face restoration |
| librosa | ≥0.10.0 | Audio processing/alignment |
| opencv-python | ≥4.8.0 | Video frame processing |
| torch | ≥2.0.0 | ML framework |
| edge-tts | ≥6.1.9 | TTS fallback (no GPU) |
| FFmpeg | ≥5.0 | Video/audio I/O |
MIT License — see LICENSE for details.
21 commits
Python
85.0%
Jupyter Notebook
15.0%