A Python library for creating dynamic subtitles with automatic speech recognition. This library combines the power of Whisper for transcription and MoviePy for video processing to create beautiful, Netflix-style subtitles for your videos.
The project is curently in progress, new styling are coming soon 🖌️
- 🎯 Automatic speech recognition using Whisper
- 🎬 Netflix-style subtitle rendering
- 📝 Support for multiple subtitle formats (SRT, VTT, ASS)
- ⚡ Fast transcription with distil-whisper
- 🎨 Customizable subtitle styling
- 🔄 Import existing subtitle files
Or using conda:
conda env create -f environment.yml
conda activate magic_subsHere's a simple example to get you started:
from magic_sub import MagicSubtitle
# Create subtitles from scratch
video = MagicSubtitle("video.mp4")
video.movie_subtitles()
video.save("video_with_subtitles.mp4")
# Or use existing subtitle file
video = MagicSubtitle("video.mp4", "subtitles.srt")
video.movie_subtitles()
video.save("video_with_subtitles.mp4")from magic_sub import Transcriber
# Initialize transcriber with custom model
transcriber = Transcriber("video.mp4", model_size="distil-whisper/distil-large-v3")
# Transcribe with specific language
subtitles = transcriber.transcribe(language="en")
# Save in different formats
transcriber.save_srt(subtitles, "output.srt")
transcriber.save_vtt(subtitles, "output.vtt")
transcriber.save_ass(subtitles, "output.ass")The library automatically handles:
- Line breaking for optimal readability
- Timing synchronization
- Positioning on screen
- Font sizing relative to video resolution
- Python 3.10 or higher (might work on older versions)
- Required packages are listed in
requirements.txt - Main dependencies:
- faster-whisper==1.1.1
- moviepy==2.1.2
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Poukilanomata