Domain Models API
whisper_vtt2srt.domain.models
SubtitleBlock
dataclass
Represents a single subtitle event containing text and timing.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
The sequential index of the subtitle (1-based). |
start |
TimeCode
|
When the subtitle appears. |
end |
TimeCode
|
When the subtitle disappears. |
lines |
List[str]
|
The text content of the subtitle, split by lines. |
Source code in whisper_vtt2srt/domain/models.py
duration_ms
property
Calculates the duration of the subtitle in milliseconds.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The duration in ms. |
TimeCode
dataclass
Represents a specific point in time used for subtitle scheduling.
Attributes:
| Name | Type | Description |
|---|---|---|
milliseconds |
int
|
The total time in milliseconds. |
Source code in whisper_vtt2srt/domain/models.py
from_str(time_str)
staticmethod
Parses a time string into a TimeCode object.
Supports standard WebVTT formats:
- MM:SS.mmm
- HH:MM:SS.mmm
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_str
|
str
|
The time string to parse (e.g., "00:01:02.500"). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TimeCode |
TimeCode
|
A new instance representing the parsed time. |
Source code in whisper_vtt2srt/domain/models.py
to_srt_string()
Formats the timecode for SRT output.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Time formatted as |