Skip to content

Friendnet-Dev/magic-subtitles

Repository files navigation

magic-subtitles

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 🖌️

Features

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

Installation

Or using conda:

conda env create -f environment.yml
conda activate magic_subs

Quick Start

Here'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")

Advanced Usage

Transcription Options

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")

Subtitle Customization

The library automatically handles:

  • Line breaking for optimal readability
  • Timing synchronization
  • Positioning on screen
  • Font sizing relative to video resolution

Requirements

  • 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

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

  • Poukilanomata

Acknowledgments

  • Whisper for the speech recognition model
  • MoviePy for video processing capabilities

About

An open-source tool for generating popular subtitle styles for your videos.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages