A Python application that automatically transcribes audio files and generates vertical videos (1080x1920) with synchronized captions - perfect for social media shorts!
- 🎤 Automatic Transcription: Uses OpenAI's Whisper for accurate speech-to-text
- 🎬 Video Generation: Creates vertical videos (1080x1920) with synchronized captions
- 🎨 Customizable Styling: Configure fonts, colors, and text positioning
- 🖼️ Image Watermarks: Add logo/branding with adjustable opacity, position, and size
- ⚙️ Flexible Configuration: JSON config file + command-line overrides
- 📱 Social Media Ready: Output format optimized for TikTok, Instagram Reels, YouTube Shorts
- Python 3.8 or higher
- ffmpeg (required by MoviePy)
On Ubuntu/Debian:
sudo apt update
sudo apt install ffmpegOn macOS:
brew install ffmpegOn Windows: Download from ffmpeg.org and add to PATH.
pip install -r requirements.txtNote: First installation will download PyTorch and Whisper models (~2GB). This may take a few minutes.
Basic usage with default settings:
python main.py input.mp3 output.mp4This will:
- Transcribe
input.mp3using Whisper - Generate
output.mp4with white text on black background - Use default font (Arial) and text styling
Edit config.json to customize default settings:
{
"video": {
"width": 1080,
"height": 1920,
"fps": 30,
"background_color": "#000000"
},
"text": {
"font": "Arial",
"font_size": 60,
"color": "#FFFFFF",
"position": "center",
"stroke_color": "#000000",
"stroke_width": 2,
"max_words_per_line": 3,
"interline": 20
},
"transcription": {
"model": "base",
"language": null
},
"watermark": {
"enabled": false,
"image_path": null,
"opacity": 0.7,
"position": "bottom-right",
"size": 0.15
}
}width,height: Video dimensions (default: 1080x1920 for vertical)fps: Frames per second (default: 30)background_color: Hex color code (e.g.,"#000000"for black)preset: Encoding speed/quality balance -"ultrafast","superfast","veryfast","faster","fast","medium","slow"(default:"fast")threads: Number of CPU threads to use for encoding (default: 8)
font: Font family name (e.g.,"Arial","Impact","Courier")font_size: Text size in pixelscolor: Text color in hex (e.g.,"#FFFFFF"for white)position: Text vertical position ("center","top","bottom")stroke_color: Outline color for better readabilitystroke_width: Outline thickness in pixelsmax_words_per_line: Words per caption (default: 3)
model: Whisper model size -tiny,base,small,medium,largetiny: Fastest, less accurate (~75MB)base: Good balance (~150MB) - recommendedsmall: Better accuracy (~500MB)medium,large: Best accuracy, slower (~1.5GB+)
language: Language code (e.g.,"en","es","fr") ornullfor auto-detect
enabled: Set totrueto enable watermark overlayimage_path: Path to watermark image file (PNG with transparency recommended)opacity: Transparency level from 0.0 (invisible) to 1.0 (fully opaque)position: Watermark placement:- Corners:
"top-left","top-right","bottom-left","bottom-right" - Edges:
"top-center","bottom-center","left-center","right-center" - Center:
"center"
- Corners:
size: Watermark size as ratio of video width (e.g.,0.15= 15% of video width)
Override config settings for individual runs:
# Custom colors
python main.py input.mp3 output.mp4 \
--text-color "#FFFF00" \
--background-color "#0000FF"
# Custom font and size
python main.py input.mp3 output.mp4 \
--font "Impact" \
--font-size 80
# Better transcription model
python main.py input.mp3 output.mp4 --model small
# Combine multiple options
python main.py input.mp3 output.mp4 \
--font "Arial" \
--font-size 70 \
--text-color "#FFD700" \
--background-color "#1a1a1a" \
--model smallpython main.py podcast.mp3 tiktok_short.mp4 \
--font "Impact" \
--font-size 80 \
--text-color "#FFFF00" \
--background-color "#000000"python main.py interview.mp3 reel.mp4 \
--font "Arial" \
--text-color "#FFFFFF" \
--background-color "#1a1a2e"python main.py tutorial.m4a short.mp4 \
--font "Arial-Bold" \
--text-color "#FF0000" \
--background-color "#FFFFFF" \
--model small- MP3 (
.mp3) - WAV (
.wav) - M4A (
.m4a) - FLAC (
.flac) - OGG (
.ogg) - MP4 (
.mp4- audio will be extracted)
- Format: MP4 (H.264 video + AAC audio)
- Resolution: 1080x1920 (vertical/portrait)
- Compatibility: Works on all major platforms (TikTok, Instagram, YouTube, etc.)
Install ffmpeg using instructions above.
Use a system font. To list available fonts:
- Linux:
fc-list : family | sort | uniq - macOS: Available in Font Book app
- Windows: Check
C:\Windows\Fonts
Safe fonts that work everywhere: Arial, Courier, Times-Roman
- Try a smaller Whisper model (
--model tinyor--model base) - Reduce FPS in config (
"fps": 24) - Use shorter audio clips for testing
- Reduce
font_sizein config - Reduce
max_words_per_linefor longer words
For quick testing, use a short audio clip (10-30 seconds) to avoid long rendering times.
Use different configs for different styles:
python main.py input.mp3 output.mp4 --config tiktok_style.jsonProcess multiple files with a simple script:
for file in *.mp3; do
python main.py "$file" "${file%.mp3}.mp4"
doneshorts-generator/
├── main.py # Main entry point
├── transcriber.py # Audio transcription module
├── video_generator.py # Video generation module
├── config.json # Default configuration
├── requirements.txt # Python dependencies
└── README.md # This file
This project is open source and available for personal and commercial use.
Contributions are welcome! Feel free to submit issues or pull requests.
Built with:
- OpenAI Whisper - Speech recognition
- MoviePy - Video editing
- Pillow - Image processing