time objects is now used by DiartDiarization class

This commit is contained in:
Quentin Fuxa
2025-02-28 18:40:42 +01:00
parent 627386a8a4
commit 7e880e039e

27
timed_objects.py Normal file
View File

@@ -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