Metadata-Version: 2.4
Name: stt2vtt
Version: 0.0.5
Summary: Convert fast-whisper STT result JSON to WebVTT
Author: Gary Lab
License: MIT License
        
        Copyright (c) 2025 audio-subtitler contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        
Project-URL: Homepage, https://github.com/garylab/stt2vtt
Project-URL: Author Blog, https://garymeng.com
Keywords: stt,vtt,webvtt,subtitles,speech-to-text,whisper,fast-whisper
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Dynamic: license-file

# 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](https://github.com/SYSTRAN/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

```bash
pip install stt2vtt
```

Dev dependencies:

```bash
pip install stt2vtt[dev]
```

## Usage

### CLI

```bash
# 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

```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](tests/test_data/jp2-input.json) for the formal format.

Example:

```json
[
  {
    "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](LICENSE).
