Skip to main content

AI-powered subtitle generation from video/audio using Whisper.

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 subtitle_generator.core import SubtitleGenerator, WhisperCppTranscriber
from subtitle_generator.models import ModelManager

transcriber = WhisperCppTranscriber(binary_path="./binary/whisper-cli")
generator = SubtitleGenerator(transcriber=transcriber, model_manager=ModelManager())

result = generator.generate(
    input_path="video.mp4",
    model_name="base",
    output_format="srt",
    output_dir="data",
)
print(f"Subtitles saved to: {result.output_path}")

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-3.0.0.tar.gz (35.9 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-3.0.0-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for subtitle_generator-3.0.0.tar.gz
Algorithm Hash digest
SHA256 adc2639c03cccb18f881ffee5b3516a1b13d200efe8c4abc3de51ba8392943ee
MD5 cac70792f846ee3ec1d4d74423a0f0eb
BLAKE2b-256 0b5083c601c085f140f7e331552b61e52601e17a8c0101683c7aa09356e4ccd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for subtitle_generator-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d0ec5fa994138307fa876656e9ec4f2335b51835ef6d58a7e23fd760d77cdd0
MD5 3c37054a8708093e2becfaa7c2a0b6f9
BLAKE2b-256 5886c0508b0680046bcb82bdf08f2f3cc788b177274af658c95a7d1ad00b933f

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