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

from src.stt_to_vtt import stt_to_vtt

# List of segments, or JSON string of that list (fast-whisper format)
vtt = stt_to_vtt('[{"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.3.tar.gz (80.0 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.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stt2vtt-0.0.3.tar.gz
  • Upload date:
  • Size: 80.0 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.3.tar.gz
Algorithm Hash digest
SHA256 f0cf776ca0b6e6815f2bd48891824eec76ab7bd46479a8f2996cec691a0a7c98
MD5 808883ef208ab1598ff53734e011a32e
BLAKE2b-256 851cccc49e2659285b702db1b3a24244129984f0adbb4405a9ea1c04c6b39d62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stt2vtt-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2979ec027b07a39d5d449e90d3063ddff4c7e9afeee0b6b853f002fa5cdb6f94
MD5 1c97c258a8582e84d01777cdddae5ccb
BLAKE2b-256 dc121a2a9bc45d547146493a6f4ae51caa71aa917cbb90b4a83aabf003bf5b43

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