Skip to main content

Subtitle processing toolkit: merge, sync, fix overlaps, and apply corrections

Project description

SubtitleKit - Subtitle Processing Toolkit

PyPI version Python 3.8+ License: MIT

Comprehensive Python library and desktop application for subtitle processing, synchronization, and correction.

✨ Features

  • Merge & Sync: Combine subtitle files with automatic synchronization
  • Fix Overlaps: Detect and correct timing issues and overlaps
  • Apply Corrections: Apply text corrections from JSON files
  • Subtitle Optimizer: Automatic CPS optimization, line reduction, filler word removal, and AI-powered shortening (via Gemini API)
  • LLM Integration: Generate optimized JSON for translation workflows
  • Desktop App: Cross-platform GUI (Windows, macOS, Linux)
  • Colab Ready: Works seamlessly in Google Colab notebooks

🚀 Quick Start

Installation

pip install subtitlekit

Google Colab

Open In Colab

# Install
!pip install subtitlekit

# Launch UI
from subtitlekit.ui import show_ui
show_ui(lang='en')  # or 'el' for Greek

As a Library

from subtitlekit import merge_subtitles, fix_overlaps, apply_corrections

# Merge subtitle files
merge_subtitles("original.srt", ["helper.srt"], "output.json")

# Fix timing overlaps
fix_overlaps("input.srt", "reference.srt", "fixed.srt")

# Apply corrections from JSON
apply_corrections("input.srt", "corrections.json", "output.srt")

CLI Usage

# Merge subtitles
subtitlekit merge --original original.srt --helper helper.srt --output output.json

# Fix overlaps
subtitlekit overlaps --input input.srt --reference ref.srt --output fixed.srt

# Apply corrections
subtitlekit corrections --input input.srt --corrections fixes.json --output corrected.srt

# Optimize subtitles
subtitlekit optimize input.srt --interjections --line-reduction --cps --llm

Desktop App

Download the standalone application from Releases.

Or launch programmatically:

python -m subtitlekit.ui.desktop

📖 Documentation

Merge Subtitles

Combines original subtitle file with one or more helper files (different languages) to create JSON output optimized for LLM translation workflows.

subtitlekit merge \
  --original movie.srt \
  --helper helpful_en.srt \
  --helper helpful_pt.srt \
  --output for_translation.json \
  --skip-sync  # optional: skip ffsubsync

Output format:

{
  "id": 1,
  "t": "00:00:11,878 --> 00:00:16,130",
  "trans": "Original text to translate",
  "h1": "Helper text (language 1)",
  "h2": "Helper text (language 2)"
}

Fix Overlaps

Detects and corrects timing issues:

  • Overlapping timestamps
  • Out-of-order entries
  • Unreasonable durations
  • Duplicate timings
subtitlekit overlaps \
  --input problematic.srt \
  --reference correct_timings.srt \
  --output fixed.srt \
  --window 5

Apply Corrections

Apply text corrections from JSON file:

subtitlekit corrections \
  --input subtitle.srt \
  --corrections fixes.json \
  --output corrected.srt

Subtitle Optimizer

Automated pipeline to improve subtitle readability and timing. Supports multiple languages (English, Greek, etc.) for interjection removal.

subtitlekit optimize movie.srt \
  --interjections \
  --line-reduction \
  --cps \
  --llm \
  --api-key YOUR_GEMINI_API_KEY

Optimization Phases:

  1. Interjection Removal: Removes filler words (e.g., "Uh,", "Well,").
  2. Line Reduction: Collapses 3+ line entries into 2 lines for better layout.
  3. CPS Optimization: Extends timing and merges short subtitles to hit target Characters Per Second (default: 20.0).
  4. LLM Shortening: Uses Gemini AI to shorten entries that still exceed CPS limits.
  5. Translation Prep: Experimental --simplify flag to simplify text for easier translation.

🌍 I18n Support

Desktop and Colab UIs support:

  • 🇬🇧 English
  • 🇬🇷 Greek (Ελληνικά)

📦 Development

# Clone repository
git clone https://github.com/angelospk/subtitlekit.git
cd subtitlekit

# Install in development mode
pip install -e .

# Run tests
pytest -v

🤝 Contributing

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

📄 License

MIT License - see LICENSE file.

🙏 Credits

Built by angelospk

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

subtitlekit-0.2.0.tar.gz (69.5 kB view details)

Uploaded Source

Built Distribution

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

subtitlekit-0.2.0-py3-none-any.whl (69.3 kB view details)

Uploaded Python 3

File details

Details for the file subtitlekit-0.2.0.tar.gz.

File metadata

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

File hashes

Hashes for subtitlekit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d4734cc5f0d79455d70cde9c1172f74828c6306d8d1b37f472a419c46796a826
MD5 54698754f5070e0523b802f73eeb7a1f
BLAKE2b-256 763005ab0490d36b87fc8283c9a26e9c6d5faf4594297997a810ba867bbc91d3

See more details on using hashes here.

File details

Details for the file subtitlekit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: subtitlekit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 69.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for subtitlekit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e9fe422065f92ad86b2a3ffb0803218d3b8252f5b0c5a85b3376cd17a00087c
MD5 18b41592043bc811fe0151fbd1befd0b
BLAKE2b-256 6a517f5056c4dfeefc439e5d12d55c0a7614522c68787d2e015456e88d223d34

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