Skip to content

Commit

Permalink
handle last element out of range error
Browse files Browse the repository at this point in the history
  • Loading branch information
itazap committed Sep 20, 2024
1 parent ac5a055 commit 7486f4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/models/whisper/tokenization_whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,9 @@ def new_chunk():
start_time = round(token_timestamps[i] + time_offset, 2)
if i + 1 < len(token_timestamps):
end_time = round(token_timestamps[i + 1] + time_offset, 2)
current_token_timestamps.append((start_time, end_time))
else:
end_time = None # should never happen
current_token_timestamps.append((start_time, end_time))

if "stride" in output:
time_offset += chunk_len - stride_right
Expand Down Expand Up @@ -1192,7 +1192,7 @@ def _find_longest_common_sequence(sequences, token_timestamp_sequences=None):
# and have timestamps that are in order
matches = sum(
1
for idx, elem in enumerate(left)
for idx, elem in enumerate(left[:-1])
if (
elem == right[idx]
and left_token_timestamp_sequence[left_start + idx]
Expand Down

0 comments on commit 7486f4b

Please sign in to comment.