Web VTT module¶
Speach supports Web VTT - The Web Video Text Tracks Format. Read more about it at: https://www.w3.org/2013/07/webvtt.html
Web Video Text Tracks format (WebVTT) support
- More information:
- WebVTT: The Web Video Text Tracks Format
- speach.vtt.sec2ts(seconds: float) str [source]¶
Convert duration in seconds in seconds to VTT format (e.g. 01:53:47.262)
>>> from speach import vtt >>> vtt.sec2ts(25.403) '00:00:25.403' >>> vtt.sec2ts(14532.768) '04:02:12.768'
- Parameters
seconds – Timestamp in seconds
- Returns
Web VTT formatted timestamp
- Return type
str
- Raises
ValueError
: when seconds is not a number or cannot be casted into a number
- speach.vtt.ts2sec(ts: str) float [source]¶
Convert VTT timestamp to duration (float, in seconds)
>>> from speach import vtt >>> vtt.ts2sec("01:00:41.231") 3641.231 >>> print(vtt.ts2sec("00:00:00.000")) 0.0
- Parameters
ts (str) – Timestamp (hh:mm:ss.nnn)
- Returns
timestamp in seconds
- Return type
float
- Raises
ValueError
: if timestamp is not formatted correctly