A powerful, local-first library and CLI for video transcription and subtitle generation using Whisper.
Project description
Auto-Subs
Effortless Subtitle Generation from Whisper Transcriptions.A powerful, local-first library and CLI for generating subtitles with precise, word-level accuracy.
Auto-Subs bridges the gap between raw transcription data and perfectly formatted subtitles. Whether you're a developer integrating transcription into your application or a content creator needing quick subtitles, auto-subs provides a robust, simple, and reliable solution.
Key Features
- 🚀 End-to-End Transcription: Go from an audio or video file directly to perfectly timed subtitles in one command.
- 🔄 Versatile Format Conversion: Easily convert existing subtitle files between supported formats.
- 🧠 Intelligent Word Segmentation: Automatically splits word-level transcriptions into perfectly timed subtitle lines based on character limits and natural punctuation breaks.
- 📄 Multiple Formats: Generate and convert subtitles in the most popular formats: SRT, VTT, and ASS.
- 🎤 Karaoke-Style Highlighting: Generate word-by-word highlighting (
{\k...}) for.assfiles, perfect for music videos or language learning. - 🛡️ Robust Validation: Automatically handles common data issues, like inverted timestamps (
start > end), ensuring your process never breaks on imperfect data. - ⚙️ Simple & Powerful API: Use it as a library with a clean, dictionary-based input that requires no complex objects, or as a feature-rich command-line tool.
Installation
# For subtitle generation and conversion
pip install auto-subs
# To include direct transcription capabilities
pip install auto-subs[transcribe]
Quickstart
As a Command-Line Tool (CLI)
auto-subs provides three powerful commands: transcribe, generate, and convert.
# 1. Transcribe a media file directly to a VTT subtitle file
auto-subs transcribe video.mp4 -f vtt --model small
# 2. Generate a styled ASS file from an existing transcription JSON
auto-subs generate input.json -f ass -o styled.ass --max-chars 42 --karaoke
# 3. Convert an existing SRT file to ASS format
auto-subs convert subtitles.srt -f ass
Each command supports batch processing directories and has more options available via --help.
As a Python Library
Integrate auto-subs directly into your application for full control.
import json
from autosubs import generate, transcribe, load
# --- Generate from existing JSON ---
with open("path/to/transcription.json", "r", encoding="utf-8") as f:
transcription_data = json.load(f)
try:
srt_content = generate(transcription_data, "srt", max_chars=40)
with open("output.srt", "w", encoding="utf-8") as f:
f.write(srt_content)
print("Successfully generated subtitles!")
except ValueError as e:
print(f"Error: {e}")
# --- Transcribe directly from a media file ---
try:
vtt_content = transcribe("path/to/video.mp4", "vtt", model_name="base")
with open("output.vtt", "w", encoding="utf-8") as f:
f.write(vtt_content)
except ImportError:
print("Transcription requires 'auto-subs[transcribe]' to be installed.")
except FileNotFoundError:
print("Media file not found.")
# --- Load and inspect an existing subtitle file ---
try:
subtitles = load("path/to/existing.srt")
print(f"Loaded {len(subtitles.segments)} subtitle segments.")
for segment in subtitles.segments:
print(f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment}")
except (ValueError, FileNotFoundError) as e:
print(f"Error loading subtitles: {e}")
API Design: Simplicity First
The public API of auto-subs is designed to be as simple as possible. All functions, like auto_subs.generate(), accept a standard Python dictionary (dict).
This approach was chosen intentionally to:
- Reduce Friction: You can directly use the JSON output from Whisper after loading it into a dictionary, without needing to import and instantiate our internal Pydantic models.
- Decouple Your Code: Your project doesn't need to depend on our internal data structures, making your code more resilient to future updates.
While the input is a simple dictionary, auto-subs performs robust internal validation to ensure the data is well-formed, giving you the best of both worlds: a simple API and the safety of strong data validation.
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you'd like to contribute code, please open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_subs-0.4.0.tar.gz.
File metadata
- Download URL: auto_subs-0.4.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecd7db48b2e8d95a7ff421fbb5bf9cfea188e4ffe69c1b82478f34565a7e67a9
|
|
| MD5 |
312c3a7495e94ee798f98ba9fab5e678
|
|
| BLAKE2b-256 |
b946a6131d9d6c783f3d384e7358f8b99b352466a73b618558779e9147ce4cea
|
File details
Details for the file auto_subs-0.4.0-py3-none-any.whl.
File metadata
- Download URL: auto_subs-0.4.0-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8298034e82965390004da568e73989bfa73ffa6a26f2d7cb19ba37e06a82e207
|
|
| MD5 |
48848780959ae3a1666bcb7b28c61513
|
|
| BLAKE2b-256 |
87753959d91900af5c775539fd88ac843c1b4c4541cafc9aa806f96caf074c35
|