From 7e880e039e8a0da8c3d83ba6d4bb7822fde055e4 Mon Sep 17 00:00:00 2001 From: Quentin Fuxa Date: Fri, 28 Feb 2025 18:40:42 +0100 Subject: [PATCH] time objects is now used by DiartDiarization class --- timed_objects.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 timed_objects.py diff --git a/timed_objects.py b/timed_objects.py new file mode 100644 index 0000000..b1baa0a --- /dev/null +++ b/timed_objects.py @@ -0,0 +1,27 @@ +from dataclasses import dataclass +from typing import Optional + +@dataclass +class TimedText: + start: Optional[float] + end: Optional[float] + text: Optional[str] = '' + speaker: Optional[int] = -1 + +@dataclass +class ASRToken(TimedText): + def with_offset(self, offset: float) -> "ASRToken": + """Return a new token with the time offset added.""" + return ASRToken(self.start + offset, self.end + offset, self.text) + +@dataclass +class Sentence(TimedText): + pass + +@dataclass +class Transcript(TimedText): + pass + +@dataclass +class SpeakerSegment(TimedText): + pass \ No newline at end of file