Skip to main content

Open-source subtitle generation for seamless content translation.

Project description

Subtitle Generator

AI-powered subtitle generation using Whisper for accurate speech-to-text transcription.

PyPI version License: MIT Python 3.9+

Features

  • 🎯 Multi-format output - VTT, SRT, TXT, JSON, LRC, ASS, TTML
  • 🚀 Fast processing - Powered by whisper.cpp for high-performance inference
  • 📦 Batch processing - Process multiple videos at once
  • 🔄 Video embedding - Embed subtitles directly into videos
  • 🌍 Multilingual - Support for multiple languages

Installation

pip install subtitle-generator

Prerequisites

  • FFmpeg is required for video/audio processing:
    # macOS
    brew install ffmpeg
    
    # Ubuntu/Debian
    sudo apt install ffmpeg
    
    # Windows (via chocolatey)
    choco install ffmpeg
    

Quick Start

# Generate subtitles (VTT format)
subtitle video.mp4

# Generate SRT format
subtitle video.mp4 --format srt

# Embed subtitles into video
subtitle video.mp4 --merge

# Use a larger model for better accuracy
subtitle video.mp4 --model large

CLI Commands

Command Description
subtitle <video> Generate subtitles for a video
subtitle models --list List available Whisper models
subtitle models --download <model> Download a specific model
subtitle batch --input-dir <dir> Batch process multiple videos
subtitle formats Show supported output formats

Options

Option Description
--model, -m Model to use: tiny, base, small, medium, large
--format, -f Output format: vtt, srt, txt, json, lrc, ass, ttml
--merge Embed subtitles into the video file
--threads, -t Number of processing threads
--verbose, -v Enable verbose output

Python API

from src.core.subtitle_gen import SubtitleGenerator

# Generate subtitles
generator = SubtitleGenerator()
result = generator.generate("video.mp4", format="srt")
print(f"Subtitles saved to: {result}")

Models

Model Size Speed Accuracy
tiny ~75MB ⚡⚡⚡⚡ ⭐⭐
base ~140MB ⚡⚡⚡ ⭐⭐⭐
small ~460MB ⚡⚡ ⭐⭐⭐⭐
medium ~1.5GB ⭐⭐⭐⭐⭐
large ~3GB 🐢 ⭐⭐⭐⭐⭐

Tip: Use .en models (e.g., base.en) for English-only content for faster processing.

Links

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtitle_generator-2.0.1.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subtitle_generator-2.0.1-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file subtitle_generator-2.0.1.tar.gz.

File metadata

  • Download URL: subtitle_generator-2.0.1.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for subtitle_generator-2.0.1.tar.gz
Algorithm Hash digest
SHA256 d83b0df30dc828dc19a9957fa2a893d1fb4cc84691af83173faa33402b66a26a
MD5 ead63d31371fa553aa7f1fe1d207ce36
BLAKE2b-256 265d90b3d1af06235b69b7cc63685abbb5f9d035a6d5b681882b8cf0d97d5ba4

See more details on using hashes here.

File details

Details for the file subtitle_generator-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for subtitle_generator-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 703fa3d1f01e527d9111619ad0c356f587b4bd1fd9942255c2a7bb8fa4beef98
MD5 a5d742e084ab4918b51fe7be5315fc20
BLAKE2b-256 d5c2d55d23b634e6d2d42b9b795ed066f8a76cf6ea3f1d2527b7a162057d7e11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page