Spaces:
Sleeping
Sleeping
Fix pad_timestamps
Browse files- src/vad.py +6 -3
src/vad.py
CHANGED
@@ -224,10 +224,11 @@ class AbstractTranscription(ABC):
|
|
224 |
def pad_timestamps(self, timestamps: List[Dict[str, Any]], padding_left: float, padding_right: float):
|
225 |
if (padding_left == 0 and padding_right == 0):
|
226 |
return timestamps
|
|
|
227 |
result = []
|
|
|
228 |
|
229 |
for i in range(len(timestamps)):
|
230 |
-
prev_entry = timestamps[i - 1] if i > 0 else None
|
231 |
curr_entry = timestamps[i]
|
232 |
next_entry = timestamps[i + 1] if i < len(timestamps) - 1 else None
|
233 |
|
@@ -243,7 +244,9 @@ class AbstractTranscription(ABC):
|
|
243 |
if (next_entry is not None):
|
244 |
segment_end = min(next_entry['start'], segment_end)
|
245 |
|
246 |
-
|
|
|
|
|
247 |
|
248 |
return result
|
249 |
|
@@ -321,7 +324,7 @@ class VadSileroTranscription(AbstractTranscription):
|
|
321 |
seconds_timestamps = self.multiply_timestamps(sample_timestamps, factor=1 / self.sampling_rate)
|
322 |
adjusted = self.adjust_timestamp(seconds_timestamps, adjust_seconds=chunk_start, max_source_time=chunk_start + chunk_duration)
|
323 |
|
324 |
-
pprint(adjusted)
|
325 |
|
326 |
result.extend(adjusted)
|
327 |
chunk_start += chunk_duration
|
|
|
224 |
def pad_timestamps(self, timestamps: List[Dict[str, Any]], padding_left: float, padding_right: float):
|
225 |
if (padding_left == 0 and padding_right == 0):
|
226 |
return timestamps
|
227 |
+
|
228 |
result = []
|
229 |
+
prev_entry = None
|
230 |
|
231 |
for i in range(len(timestamps)):
|
|
|
232 |
curr_entry = timestamps[i]
|
233 |
next_entry = timestamps[i + 1] if i < len(timestamps) - 1 else None
|
234 |
|
|
|
244 |
if (next_entry is not None):
|
245 |
segment_end = min(next_entry['start'], segment_end)
|
246 |
|
247 |
+
new_entry = { 'start': segment_start, 'end': segment_end }
|
248 |
+
prev_entry = new_entry
|
249 |
+
result.append(new_entry)
|
250 |
|
251 |
return result
|
252 |
|
|
|
324 |
seconds_timestamps = self.multiply_timestamps(sample_timestamps, factor=1 / self.sampling_rate)
|
325 |
adjusted = self.adjust_timestamp(seconds_timestamps, adjust_seconds=chunk_start, max_source_time=chunk_start + chunk_duration)
|
326 |
|
327 |
+
#pprint(adjusted)
|
328 |
|
329 |
result.extend(adjusted)
|
330 |
chunk_start += chunk_duration
|