fix whisper hallucination outside of audio length

This commit is contained in:
m-bain
2022-12-29 10:54:23 +00:00
committed by GitHub
parent 644b04e8d1
commit 93d661f2e4

View File

@ -292,6 +292,10 @@ def align(
prev_t2 = 0
word_segments_list = []
for idx, segment in enumerate(transcript):
if int(segment['start'] * SAMPLE_RATE) >= audio.shape[1]:
# original whisper error, transcript is outside of duration of audio, not possible. Skip to next (finish).
continue
t1 = max(segment['start'] - extend_duration, 0)
t2 = min(segment['end'] + extend_duration, MAX_DURATION)
if start_from_previous and t1 < prev_t2: