Create AI-generated dubbed audio tracks for media via CLI and SDK
Project description
Dubbify
Create AI-generated dubbed audio tracks for media via CLI and SDK.
Author: Amr Osama
Repository: https://github.com/thehorse2000/dubbify
Installation
pip install dubbify
Dependencies
- Python 3.9
- Python packages (installed automatically with
pip install dubbify):- typer0.12.3
- rich13.7.1
- pydantic2.7.1
- srt3.5.3
- pydub0.25.1
- ffmpeg-python0.2.0
- elevenlabs1.3.1
- openai1.40.0
- System dependency: FFmpeg (required for audio processing and muxing)
Install FFmpeg:
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y ffmpeg
# macOS (Homebrew)
brew install ffmpeg
# Windows (Chocolatey)
choco install ffmpeg
Configuration
Set API keys and default model as environment variables:
export OPENAI_API_KEY="sk-..." # used for transcription only
export ELEVENLABS_API_KEY="your_elevenlabs_key" # used for TTS only
export DUBBIFY_TTS_MODEL="eleven_multilingual_v2" # optional, defaults to eleven_multilingual_v2
CLI Usage
- End-to-end:
dubbify run \
--input path/to/video.mp4 \
--output path/to/dubbed_video.mp4 \
--voice asDeXBMC8hUkhqqL7agO \
--language en
- Transcribe only:
dubbify transcribe \
--input path/to/video.mp4 \
--output path/to/transcript.srt \
--language en
- Dub from SRT:
dubbify dub \
--input path/to/transcript.srt \
--output path/to/dubbed_audio.mp3 \
--voice asDeXBMC8hUkhqqL7agO
Notes:
--voice-idcan be provided to use the ElevenLabs Convert endpoint explicitly; if omitted,--voiceis treated as the ID.--outputaccepts.mp3(audio only) or.mp4(video with replaced audio).- Run
dubbify --helpto list all options.
SDK Usage
from dubbify import Dubbify, DubbifyConfig
config = DubbifyConfig(voice="Bella", language="en")
project = Dubbify(config=config)
project.run(input_path="path/to/video.mp4", output_path="path/to/dubbed_video.mp4")
More examples:
# Transcribe to an SRT file
project.transcribe(input_path="path/to/video.mp4", output_srt_path="out.srt")
# Generate dubbed audio from an existing SRT
project.dub(srt_path="out.srt", output_audio_path="dubbed.mp3")
How it Works
-
Transcription pipeline:
- Extracts audio from video with FFmpeg when needed.
- Splits long audio into size-limited chunks for reliable cloud transcription.
- Uses OpenAI Whisper (translations for English target, transcriptions otherwise) to produce time-stamped segments.
- Optionally translates subtitles when a non-English
languageis set. - Optionally refines SRT timings via an OpenAI text model to improve dubbing pace while preserving total duration.
-
Dubbing pipeline:
- For each subtitle line, synthesizes speech with ElevenLabs.
- Prefers the modern Convert endpoint when available (
voice_idorvoiceas ID); otherwise falls back togenerate.
- Prefers the modern Convert endpoint when available (
- Measures each synthesized clip’s duration and schedules overlays using a forward-push plus backward reconciliation algorithm to keep the final end time consistent.
- Assembles a single audio track and, if output is
.mp4, swaps the original audio with the dubbed track using FFmpeg while copying the video stream.
- For each subtitle line, synthesizes speech with ElevenLabs.
Environment requirements:
OPENAI_API_KEYis required for transcription/translation and timing refinement.ELEVENLABS_API_KEYis required for TTS.- FFmpeg must be installed and available on PATH.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dubbify-0.0.1.tar.gz.
File metadata
- Download URL: dubbify-0.0.1.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
703f212720af8dc839558df4dd4c07e80837ede11dbdb5f8debc19f9e6c932ad
|
|
| MD5 |
f8ca2842bec5dd83575b61ad07f000e1
|
|
| BLAKE2b-256 |
bbd7b185f5293b04b3a900e2d393e9897ec266e4623f80613d06ce6a16fa72d5
|
File details
Details for the file dubbify-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dubbify-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd188a6c930e437b336a89a27c15eb048da0550a3bb74b6e2c7948448f4266cb
|
|
| MD5 |
23d10eb00e98fff3d943b54569a6e5c5
|
|
| BLAKE2b-256 |
9435667e5fffcae4641cae958d20830e5f29316c68663f4ccd7d22b0aacde507
|