Fix VAD index error when a predicted timestamps is too large (#107)

This commit is contained in:
Guillaume Klein
2023-04-03 19:34:54 +02:00
committed by GitHub
parent 8c36ac1be8
commit 2f266eb844

View File

@@ -208,7 +208,10 @@ class SpeechTimestampsMap:
def get_chunk_index(self, time: float) -> int:
sample = int(time * self.sampling_rate)
return bisect.bisect(self.chunk_end_sample, sample)
return min(
bisect.bisect(self.chunk_end_sample, sample),
len(self.chunk_end_sample) - 1,
)
@functools.lru_cache