Skip to content

Repository files navigation

🎙️ DubAPI: YouTube Transcription, Translation & Dubbing Service

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.


🚀 Features

  • 🎥 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

🧱 Tech Stack

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+

📁 Folder Structure

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

🛠️ Setup Instructions

🔧 Local Setup

  1. Clone the repository
git clone https://github.com/adityailab/dub-api.git
cd dub-api
  1. Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run the app
uvicorn main:app --host 0.0.0.0 --port 8000
  1. Open in browser:
http://localhost:8000/docs

🐳 Docker Deployment

  1. Build Docker image
docker build -t dub-api .
  1. Run Docker container
docker run -p 8000:8000 dub-api

📤 API Usage

🔹 POST /dub

Description: 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"
}

🔄 Workflow

  1. Input: User submits a YouTube video URL and a target language code (e.g., "hi" for Hindi).
  2. Download: Audio is extracted from the video.
  3. Transcribe: Whisper generates a text transcript.
  4. Translate: The text is translated using Google Translate.
  5. Dub: The translated text is converted to speech using gTTS.
  6. Output: A downloadable audio file of the dubbed speech is returned.

✅ Supported Languages

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.


🧠 Future Enhancements

  • 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages