Spaces:
Running
Running
Delete README.md
Browse files
README.md
DELETED
|
@@ -1,202 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Video Editing
|
| 3 |
-
emoji: 🚀
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: red
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 8501
|
| 8 |
-
tags:
|
| 9 |
-
- streamlit
|
| 10 |
-
pinned: false
|
| 11 |
-
short_description: Streamlit template space
|
| 12 |
-
license: mit
|
| 13 |
-
---
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Welcome to Streamlit!
|
| 17 |
-
|
| 18 |
-
Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
|
| 19 |
-
|
| 20 |
-
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
|
| 21 |
-
forums](https://discuss.streamlit.io).
|
| 22 |
-
|
| 23 |
-
---
|
| 24 |
-
title: Movie Dubber — Any Language to Hindi
|
| 25 |
-
emoji: 🎬
|
| 26 |
-
colorFrom: red
|
| 27 |
-
colorTo: orange
|
| 28 |
-
sdk: streamlit
|
| 29 |
-
sdk_version: 1.32.0
|
| 30 |
-
app_file: app.py
|
| 31 |
-
pinned: false
|
| 32 |
-
license: mit
|
| 33 |
-
short_description: Dub any video to Hindi — 100% free, open-source, CPU-only
|
| 34 |
-
---
|
| 35 |
-
|
| 36 |
-
# 🎬 Movie Dubber — Any Language → Hindi
|
| 37 |
-
|
| 38 |
-
Dub any video into Hindi automatically. Upload an MP4, get a Hindi dubbed video. 100% free, open-source, runs on CPU.
|
| 39 |
-
|
| 40 |
-
---
|
| 41 |
-
|
| 42 |
-
## 🚀 Features
|
| 43 |
-
|
| 44 |
-
| Feature | How it works |
|
| 45 |
-
|---------|-------------|
|
| 46 |
-
| 🎥 Upload video | MP4, AVI, MKV, MOV supported |
|
| 47 |
-
| 🔊 Extract audio | ffmpeg pulls clean audio from video |
|
| 48 |
-
| 📝 Transcribe speech | faster-whisper (CPU-optimised Whisper) with timestamps |
|
| 49 |
-
| 🌏 Translate to Hindi | Helsinki-NLP MarianMT — free, no API key |
|
| 50 |
-
| ✏️ Manual editing | Edit any translated line before generating speech |
|
| 51 |
-
| 🗣️ Hindi TTS | gTTS — natural Hindi speech, instant generation |
|
| 52 |
-
| 🎬 Merge video | ffmpeg merges Hindi audio with original BGM |
|
| 53 |
-
| ⬇️ Download | Get final dubbed MP4 |
|
| 54 |
-
|
| 55 |
-
---
|
| 56 |
-
|
| 57 |
-
## 📁 Project Structure
|
| 58 |
-
|
| 59 |
-
```
|
| 60 |
-
movie_dubber/
|
| 61 |
-
├── app.py ← Main Streamlit app
|
| 62 |
-
├── requirements.txt ← Python dependencies
|
| 63 |
-
├── README.md ← This file
|
| 64 |
-
└── utils/
|
| 65 |
-
├── __init__.py
|
| 66 |
-
├── audio_utils.py ← Audio extraction & silence detection
|
| 67 |
-
├── transcribe_utils.py ← Whisper transcription
|
| 68 |
-
├── translate_utils.py ← MarianMT translation
|
| 69 |
-
├── tts_utils.py ← Hindi TTS generation
|
| 70 |
-
└── video_utils.py ← FFmpeg video merge
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
---
|
| 74 |
-
|
| 75 |
-
## 🤗 Deploy on Hugging Face Spaces (5 minutes)
|
| 76 |
-
|
| 77 |
-
### Step 1 — Create a new Space
|
| 78 |
-
|
| 79 |
-
1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
|
| 80 |
-
2. Click **"Create new Space"**
|
| 81 |
-
3. Fill in:
|
| 82 |
-
- **Space name:** `movie-dubber` (or any name)
|
| 83 |
-
- **SDK:** Streamlit
|
| 84 |
-
- **Hardware:** CPU Basic (free)
|
| 85 |
-
4. Click **"Create Space"**
|
| 86 |
-
|
| 87 |
-
### Step 2 — Upload files
|
| 88 |
-
|
| 89 |
-
Option A — via the web UI:
|
| 90 |
-
1. In your new Space, click **"Files"** tab
|
| 91 |
-
2. Click **"Add file → Upload files"**
|
| 92 |
-
3. Upload: `app.py`, `requirements.txt`, `README.md`
|
| 93 |
-
4. Create a `utils/` folder and upload all 5 util files
|
| 94 |
-
|
| 95 |
-
Option B — via Git:
|
| 96 |
-
```bash
|
| 97 |
-
git clone https://huggingface.co/spaces/YOUR_USERNAME/movie-dubber
|
| 98 |
-
cd movie-dubber
|
| 99 |
-
# copy all project files here
|
| 100 |
-
git add .
|
| 101 |
-
git commit -m "initial deploy"
|
| 102 |
-
git push
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
### Step 3 — Wait for build
|
| 106 |
-
|
| 107 |
-
Hugging Face will automatically:
|
| 108 |
-
1. Install all `requirements.txt` packages
|
| 109 |
-
2. Start your Streamlit app
|
| 110 |
-
3. Show it live at `https://huggingface.co/spaces/YOUR_USERNAME/movie-dubber`
|
| 111 |
-
|
| 112 |
-
> ⏱ First build takes ~3–5 minutes (downloading models)
|
| 113 |
-
|
| 114 |
-
---
|
| 115 |
-
|
| 116 |
-
## 💻 Run Locally
|
| 117 |
-
|
| 118 |
-
### Prerequisites
|
| 119 |
-
- Python 3.9+
|
| 120 |
-
- ffmpeg installed: `brew install ffmpeg` (Mac) or `sudo apt install ffmpeg` (Linux)
|
| 121 |
-
|
| 122 |
-
### Setup
|
| 123 |
-
|
| 124 |
-
```bash
|
| 125 |
-
# 1. Clone / download the project
|
| 126 |
-
git clone https://huggingface.co/spaces/YOUR_USERNAME/movie-dubber
|
| 127 |
-
cd movie-dubber
|
| 128 |
-
|
| 129 |
-
# 2. Create virtual environment
|
| 130 |
-
python -m venv venv
|
| 131 |
-
source venv/bin/activate # Windows: venv\Scripts\activate
|
| 132 |
-
|
| 133 |
-
# 3. Install dependencies
|
| 134 |
-
pip install -r requirements.txt
|
| 135 |
-
|
| 136 |
-
# 4. Run the app
|
| 137 |
-
streamlit run app.py
|
| 138 |
-
```
|
| 139 |
-
|
| 140 |
-
Open your browser at `http://localhost:8501`
|
| 141 |
-
|
| 142 |
-
---
|
| 143 |
-
|
| 144 |
-
## ⚙️ How Each Feature Works (Simple English)
|
| 145 |
-
|
| 146 |
-
### 🔊 Audio Extraction
|
| 147 |
-
We use **ffmpeg** to pull the audio out of your video file and save it as a WAV file at 16kHz. This format is what Whisper expects.
|
| 148 |
-
|
| 149 |
-
### 📝 Transcription (Speech → Text)
|
| 150 |
-
We use **faster-whisper** — a faster version of OpenAI's Whisper model. It listens to the audio and converts speech to text, along with start/end timestamps for each spoken phrase.
|
| 151 |
-
- `tiny` model: fastest, good enough for clear speech
|
| 152 |
-
- `base` model: best balance (recommended)
|
| 153 |
-
- `small` model: most accurate, but 3–5 min per minute of audio on CPU
|
| 154 |
-
|
| 155 |
-
### 🌏 Translation (Text → Hindi)
|
| 156 |
-
We use **Helsinki-NLP MarianMT** models from Hugging Face. These are small neural machine translation models that run on CPU.
|
| 157 |
-
- If your video is in a language with a direct → Hindi model, we use that
|
| 158 |
-
- Otherwise we pivot: source language → English → Hindi (two steps)
|
| 159 |
-
|
| 160 |
-
### ✏️ Manual Editing
|
| 161 |
-
Before generating speech, you can edit any translated Hindi text directly in the app. This is important because machine translation isn't always perfect for movie dialogue.
|
| 162 |
-
|
| 163 |
-
### 🗣️ Hindi TTS (Text → Speech)
|
| 164 |
-
We use **gTTS** (Google Text-to-Speech) which is free and instant. It produces natural-sounding Hindi speech. Each segment is generated separately and placed at the correct timestamp.
|
| 165 |
-
|
| 166 |
-
### 🎬 Video Merge
|
| 167 |
-
We use **ffmpeg** to:
|
| 168 |
-
1. Lower the original audio volume (keeps background music faintly audible)
|
| 169 |
-
2. Mix the Hindi speech on top
|
| 170 |
-
3. Combine with the original video stream (no re-encoding = fast!)
|
| 171 |
-
|
| 172 |
-
---
|
| 173 |
-
|
| 174 |
-
## ⚠️ Limitations
|
| 175 |
-
|
| 176 |
-
| Limitation | Why | Workaround |
|
| 177 |
-
|------------|-----|------------|
|
| 178 |
-
| Slow transcription on CPU | Whisper is GPU-optimised | Use `tiny` or `base` model, keep videos short |
|
| 179 |
-
| No real speaker diarization | pyannote.audio needs GPU | Heuristic speaker switching is used |
|
| 180 |
-
| No lip sync | Wav2Lip needs GPU | Speed-fitting keeps audio roughly in sync |
|
| 181 |
-
| gTTS needs internet | It's an HTTP request | Works fine on HF Spaces |
|
| 182 |
-
| File size limit | HF Spaces has RAM limits | Keep videos under 200MB |
|
| 183 |
-
|
| 184 |
-
---
|
| 185 |
-
|
| 186 |
-
## 🛠️ Tech Stack
|
| 187 |
-
|
| 188 |
-
| Component | Library | Why |
|
| 189 |
-
|-----------|---------|-----|
|
| 190 |
-
| Web UI | Streamlit | Easy, HF Spaces native |
|
| 191 |
-
| Audio extraction | ffmpeg | Universal, fast |
|
| 192 |
-
| Silence detection | pydub + librosa | Lightweight |
|
| 193 |
-
| Transcription | faster-whisper | 4× faster than Whisper on CPU |
|
| 194 |
-
| Translation | transformers (MarianMT) | Free, offline, good quality |
|
| 195 |
-
| TTS | gTTS | Free, natural Hindi, instant |
|
| 196 |
-
| Video merge | ffmpeg | Fast (copies video, no re-encode) |
|
| 197 |
-
|
| 198 |
-
---
|
| 199 |
-
|
| 200 |
-
## 📄 License
|
| 201 |
-
|
| 202 |
-
MIT — free to use, modify, and deploy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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