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 JSON 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
stt2vtt result.json -o output.vtt

# To stdout
stt2vtt result.json

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

Python

from src.stt_to_vtt import stt_to_vtt

# JSON string or parsed list of segments (fast-whisper format)
vtt = stt_to_vtt('[{"id": 1, "start": 0, "end": 1, "text": "...", "words": [...]}]')

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

Input format (fast-whisper)

A JSON array of segments. Each segment has start, end, text (in seconds), and words: list of {start, end, word}. Optional: id, probability on words.

[
  {
    "id": 1,
    "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." }
    ]
  }
]

A dict with a segments key is also accepted: stt_to_vtt({"segments": [...]}).

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.2.tar.gz (79.9 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.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stt2vtt-0.0.2.tar.gz
  • Upload date:
  • Size: 79.9 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.2.tar.gz
Algorithm Hash digest
SHA256 70610113a124d8721d243e58ac4575d584580175f6e59db3b8581d640b3045d3
MD5 9dd4249235fee091916eb5e4691d8147
BLAKE2b-256 b75cac7f91602ed5dde9ade69f5461917d95655536dedecfc6921f8c22ca6079

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stt2vtt-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5489d492cf352f7c7dadcd20b73633f2624a741e385c370809f9ec872b8a1635
MD5 c6959e86442c87619b525d4bee5d1333
BLAKE2b-256 f17dbc3e7042d52d93df0f2d8072834156323c0b8fca9c44c4f45237ccaac842

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