Spaces:
Paused
Paused
Commit ·
2e9d9e5
1
Parent(s): a497b09
Dedicated models: one piece per sentence (they drop what follows the first sentence)
Browse files
src/transcription/language_runs.py
CHANGED
|
@@ -233,19 +233,21 @@ def drop_repeats(segments: List[Dict]) -> List[Dict]:
|
|
| 233 |
return out
|
| 234 |
|
| 235 |
|
| 236 |
-
|
|
|
|
| 237 |
|
| 238 |
|
| 239 |
-
def pieces(windows: List[Window], start: float, end: float, max_len: float =
|
| 240 |
-
"""Speech inside [start, end]
|
| 241 |
-
|
| 242 |
-
|
|
|
|
| 243 |
out: List[List[float]] = []
|
| 244 |
for w in windows:
|
| 245 |
if w.end <= start or w.start >= end:
|
| 246 |
continue
|
| 247 |
s, e = max(w.start, start), min(w.end, end)
|
| 248 |
-
if out and e - out[-1][0] <= max_len:
|
| 249 |
out[-1][1] = e
|
| 250 |
else:
|
| 251 |
out.append([s, e])
|
|
|
|
| 233 |
return out
|
| 234 |
|
| 235 |
|
| 236 |
+
PIECE_MAX_SEC = 15.0
|
| 237 |
+
SHORT_PIECE_SEC = 2.5
|
| 238 |
|
| 239 |
|
| 240 |
+
def pieces(windows: List[Window], start: float, end: float, max_len: float = PIECE_MAX_SEC) -> List[Tuple[float, float]]:
|
| 241 |
+
"""Speech inside [start, end] as one piece per sentence (the windows are
|
| 242 |
+
already cut at pauses). The dedicated Yoruba/Igbo/Hausa models transcribe
|
| 243 |
+
one sentence reliably but drop whatever follows it in a longer piece, so
|
| 244 |
+
pieces are only joined when one side is a short fragment."""
|
| 245 |
out: List[List[float]] = []
|
| 246 |
for w in windows:
|
| 247 |
if w.end <= start or w.start >= end:
|
| 248 |
continue
|
| 249 |
s, e = max(w.start, start), min(w.end, end)
|
| 250 |
+
if out and e - out[-1][0] <= max_len and (out[-1][1] - out[-1][0] < SHORT_PIECE_SEC or e - s < SHORT_PIECE_SEC):
|
| 251 |
out[-1][1] = e
|
| 252 |
else:
|
| 253 |
out.append([s, e])
|