Skip to main content

gosavetool-subtitles

Parse, convert, shift and repair SRT and WebVTT subtitles in Python. No dependencies, typed, with a command line tool.

Handy after speech-to-text: turn Whisper's SRT into WebVTT for the web, move captions that run late, and clean up overlaps.

Made by GoSaveTool. Prefer a visual editor? The VTT Subtitle Generator times captions against the video in your browser.

Install

pip install gosavetool-subtitles

Convert SRT to WebVTT

from pathlib import Path
from gosavetool_subtitles import convert

Path("movie.vtt").write_text(convert(Path("movie.srt").read_text("utf-8"), "vtt"), "utf-8")

Work with cues

from gosavetool_subtitles import parse, shift, repair, to_srt

cues = parse(text)              # [Cue(start=1000, end=3500, text='Hello', settings=''), ...]
later = shift(cues, 1500)       # every cue 1.5 s later (negative = earlier)
fixed, changes = repair(cues)   # sort, fix overlaps and bad end times, drop empty cues
Path("out.srt").write_text(to_srt(fixed), "utf-8")
Function Returns
parse(text) Cue list of an SRT or WebVTT text, times in milliseconds
to_srt(cues) / to_vtt(cues) Subtitle text; SRT is renumbered from 1
convert(text, "srt" or "vtt") Converted text in one call
shift(cues, ms) Cues moved by ms; cues before 0 are clipped or dropped
repair(cues, min_duration=2000) (cues, number_of_changes)
is_vtt(text) True when the text starts with WEBVTT
to_ms("00:01:02,500") / from_ms(62500, ".") Timestamp and milliseconds

Command line

gosavetool-subtitles convert movie.srt --to vtt
gosavetool-subtitles shift movie.srt -1.5
gosavetool-subtitles repair movie.vtt
gosavetool-subtitles info movie.srt

-o out.vtt writes to another file, --stdout prints the result. python -m gosavetool_subtitles works too.

License

MIT

Metadata

Release files for gosavetool-subtitles 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gosavetool-subtitles 1.0.0
File Size Uploaded Provenance Actions
gosavetool_subtitles-1.0.0.tar.gz 7.2 kB Without provenance Details for gosavetool_subtitles-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gosavetool-subtitles 1.0.0
File Interpreter ABI Platform Actions
gosavetool_subtitles-1.0.0-py3-none-any.whl Python 3 none any Details for gosavetool_subtitles-1.0.0-py3-none-any.whl

Total release size: 14.2 kB

Release files / gosavetool_subtitles-1.0.0.tar.gz

Download URL gosavetool_subtitles-1.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
03518e174af5cccf751f1723dd7f4f14a47ad80e71ac56dbbdfde7fdeeffc4c3
BLAKE2b-256 checksum
How to use checksums
0888840f8df9d5df08ef0efb131853e8ce9449328730a1afee11dd02968d2745
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / gosavetool_subtitles-1.0.0-py3-none-any.whl

Download URL gosavetool_subtitles-1.0.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e146b65000084b871cfafdd1174fe4678b37b569a7396ca435b8e679f6e8713
BLAKE2b-256 checksum
How to use checksums
444e4e1aefffe86ae6db8421aa972a4aebb737916eee552fef44cabf3b99d889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for gosavetool-subtitles 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page