qfuxa commited on
Commit
fe0200a
·
1 Parent(s): 1ac9078

time objects is now used by DiartDiarization class

Browse files
Files changed (1) hide show
  1. timed_objects.py +27 -0
timed_objects.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+
4
+ @dataclass
5
+ class TimedText:
6
+ start: Optional[float]
7
+ end: Optional[float]
8
+ text: Optional[str] = ''
9
+ speaker: Optional[int] = -1
10
+
11
+ @dataclass
12
+ class ASRToken(TimedText):
13
+ def with_offset(self, offset: float) -> "ASRToken":
14
+ """Return a new token with the time offset added."""
15
+ return ASRToken(self.start + offset, self.end + offset, self.text)
16
+
17
+ @dataclass
18
+ class Sentence(TimedText):
19
+ pass
20
+
21
+ @dataclass
22
+ class Transcript(TimedText):
23
+ pass
24
+
25
+ @dataclass
26
+ class SpeakerSegment(TimedText):
27
+ pass