Skip to main content

Convert fast-whisper STT result JSON to WebVTT

Project description

stt2vtt

Convert fast-whisper STT results with timestamps to WebVTT. Input is a list of segments (or a JSON string of that list) from faster-whisper or compatible segment + word timestamps. Output is VTT text.

No audio processing or ML models — this repo only converts existing STT JSON to VTT.

Installation

pip install stt2vtt

Dev dependencies:

pip install stt2vtt[dev]

Usage

CLI

# From file (writes <stem>.vtt in current directory by default)
stt2vtt result.json
# → result.vtt

# Custom output path
stt2vtt result.json -o output.vtt

# From stdin
cat result.json | stt2vtt -o output.vtt

Python

import stt2vtt

# Call the package: list of segments, or JSON string of that list (fast-whisper format)
vtt = stt2vtt('[{"start": 0, "end": 1.5, "text": " Hello world.", "words": [{"start": 0, "end": 0.5, "word": " Hello"}, {"start": 0.5, "end": 1.5, "word": " world."}]}]')

print(vtt)  # "WEBVTT\n\n00:00:00.000 --> ..."

Input format (fast-whisper)

Input must be a list of segments or a JSON string of that list (no wrapper object).

Minimal schema:

  • Segment: start, end (seconds), text, words (list, default []).
  • Word (each item in words): start, end, word.

Extra fields in the JSON are ignored. See tests/test_data/jp2-input.json for the formal format.

Example:

[
  {
    "start": 0.0,
    "end": 1.5,
    "text": " Hello world.",
    "words": [
      { "start": 0.0, "end": 0.5, "word": " Hello" },
      { "start": 0.5, "end": 1.5, "word": " world." }
    ]
  }
]

Segments without words are allowed; one VTT cue is emitted per segment using segment start, end, and text.

Output

WebVTT subtitle content: a WEBVTT header plus timestamped cues. Sentence boundaries are split on punctuation; the first letter of each cue is capitalized.

Example (from the input above):

WEBVTT

00:00:00.000 --> 00:00:01.500
Hello world

License

MIT — see LICENSE.

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

stt2vtt-0.0.5.tar.gz (117.2 kB view details)

Uploaded Source

Built Distribution

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

stt2vtt-0.0.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file stt2vtt-0.0.5.tar.gz.

File metadata

  • Download URL: stt2vtt-0.0.5.tar.gz
  • Upload date:
  • Size: 117.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stt2vtt-0.0.5.tar.gz
Algorithm Hash digest
SHA256 cdae0d27ca9028b66da4658e0820db1397dc02b45422c8db540e3813a5d9fe34
MD5 0ffce96d71c9986fc341bdb78bf7ee4f
BLAKE2b-256 e0bdcc2c6be2837f31a3fb50fbc7a37050aaa6b8406f04958da2874f30ffa00f

See more details on using hashes here.

File details

Details for the file stt2vtt-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: stt2vtt-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for stt2vtt-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4e5ef6dcf3921967abe88a5a922cf951a6bf9802d8e63937a891b243e0e48d5c
MD5 c10f7e27f14df15860bc403c7081d1f6
BLAKE2b-256 e2075915e03dc0e136dd3853ad3961fa0109570b8188fcbe7115abe8bb0d3d31

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