DubAPI is a FastAPI-based application that automates the pipeline of transcribing YouTube videos, translating them into a target language, and generating dubbed audio using text-to-speech. It is designed for scalability and ease of integration, making it ideal for multilingual content creation, accessibility solutions, and educational applications.
- 🎥 YouTube Video Input — Extracts audio from a given YouTube URL
- 📝 Transcription — Converts audio to text using OpenAI's Whisper
- 🌐 Translation — Translates the transcript into any supported language via Google Translate
- 🔊 Dubbing — Synthesizes speech in the target language using gTTS
- ⚙️ API-First Design — Clean FastAPI implementation with Swagger docs
- 🐳 Dockerized — Easily deployable via Docker
- ☁️ Cloud Ready — Tested on Render, suitable for any cloud provider
| Component | Tool / Library |
|---|---|
| Backend API | FastAPI |
| Transcription | OpenAI Whisper |
| Translation | googletrans (Google Translate API) |
| Text-to-Speech | gTTS (Google Text-to-Speech) |
| Deployment | Docker, Render |
| Language | Python 3.9+ |
dub-api/
│
├── main.py # FastAPI app & routes
├── dubbing.py # Core logic: download, transcribe, translate, dub
├── utils.py # Helper functions for file I/O and processing
├── requirements.txt
├── Dockerfile
└── README.md
- Clone the repository
git clone https://github.com/adityailab/dub-api.git
cd dub-api- Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Run the app
uvicorn main:app --host 0.0.0.0 --port 8000- Open in browser:
http://localhost:8000/docs
- Build Docker image
docker build -t dub-api .- Run Docker container
docker run -p 8000:8000 dub-apiDescription: Submits a YouTube video for transcription, translation, and dubbing.
Request Body:
{
"video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"target_language": "es"
}Response:
{
"status": "success",
"dubbed_audio_url": "https://your-server.com/audio/output_hi.mp3"
}- Input: User submits a YouTube video URL and a target language code (e.g., "hi" for Hindi).
- Download: Audio is extracted from the video.
- Transcribe: Whisper generates a text transcript.
- Translate: The text is translated using Google Translate.
- Dub: The translated text is converted to speech using gTTS.
- Output: A downloadable audio file of the dubbed speech is returned.
Supports all languages offered by:
- OpenAI Whisper (for transcription)
- Google Translate (for translation)
- gTTS (for TTS)
Note: Voice quality and language availability may vary with gTTS.
- Replace gTTS with more natural TTS models (e.g., ElevenLabs, Bark, Coqui)
- Add video generation with dubbed audio (not just audio output)
- Upload results to S3 or GCP for persistent storage
- Add language auto-detection from audio
- Frontend UI for file upload and interaction