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.4.tar.gz (80.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.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stt2vtt-0.0.4.tar.gz
  • Upload date:
  • Size: 80.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.4.tar.gz
Algorithm Hash digest
SHA256 72c2aaa51229a957c66ef19e73af5dcd2518ca69e115b269c2acf85c4abf42e0
MD5 ce5cef4e39e8d7db6d6f8fbdc853e7ff
BLAKE2b-256 b486d3968017fbe6ad4f787358b515e0e5d619f658e7ba1f7c48b4a44d2ebbcb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stt2vtt-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 21d98b436346f2c3037960a856c7a0f0f9fa8ddd56a91416ff64d349b042fb77
MD5 e241c3e43ded0d6b93a480340fbd4518
BLAKE2b-256 1e8053847c49227f3657f27f3c3c455675aea3efb31a2426123c8e966d119511

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