lacing.adapters.webvtt#
WebVTT (W3C TimedText) adapter.
WebVTT is a flat caption format: one stream of cues, no tier hierarchy. Cues have a start time, an end time, optional id and settings, and a payload (text with limited inline markup).
We map cues to a single tier named cues (override with tier=).
Each cue becomes one Annotation whose body holds:
{“text”: str, “id”: str | None, “settings”: dict[str, str]}
- Lossy fields on dump:
Provenance, confidence, schema URIs, and tier metadata are dropped. Only the text, id (if present), and settings are emitted.
- Time discipline:
WebVTT timestamps are
HH:MM:SS.mmmorMM:SS.mmm(with milliseconds). Parsing goes through string fractions to avoid float ingestion. Default rate is 1000 (millisecond precision); override withrate=if your project uses a different canonical rate.
Spec: https://www.w3.org/TR/webvtt1/
Functions
|
Write annotations as WebVTT. |
|
Parse a WebVTT file or string/bytes into a |
- lacing.adapters.webvtt.dump(store, target=None, *, tier=None, **_kwargs)[source]#
Write annotations as WebVTT.
- Parameters:
store (
IntervalAnnotationStore) – Source store. Only annotations fromtier(default: all tiers) with aMediaRefinterval are emitted, sorted by start.target (
str|PathLike|None) – Output path. If None, returns bytes (UTF-8).tier (
str|None) – Restrict export to this tier. None = export all annotations.
- Return type: