time objects is now used by DiartDiarization class
This commit is contained in:
parent
627386a8a4
commit
7e880e039e
1 changed files with 27 additions and 0 deletions
27
timed_objects.py
Normal file
27
timed_objects.py
Normal 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
|
||||||
Loading…
Reference in a new issue