Skip to content

Commit de85851

Browse files
committed
TimedText contains same methods as in WLK
1 parent 06fc36e commit de85851

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

nllw/timed_text.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ class TimedText:
66
text: Optional[str] = None
77
start: Optional[float] = 0
88
end: Optional[float] = 0
9+
10+
def duration(self) -> float:
11+
return self.end - self.start
12+
13+
def contains_time(self, time: float) -> bool:
14+
return self.start <= time <= self.end
15+
16+
def contains_timespan(self, other: 'TimedText') -> bool:
17+
return self.start <= other.start and self.end >= other.end
918

1019
def overlaps_with(self, other: 'TimedText') -> bool:
1120
return not (self.end <= other.start or other.end <= self.start)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "nllw"
7-
version = "0.1.1"
7+
version = "0.1.1.post1"
88
description = "Simultaneous Machine Translation (SimulMT) with NLLB model optimization"
99
readme = "README.md"
1010
requires-python = ">=3.8"

0 commit comments

Comments
 (0)