Skip to content

Commit

Permalink
Fix timestamp jumptimes indexOutofBoundsError based on Issue in origi…
Browse files Browse the repository at this point in the history
…nal repo huggingface#12
  • Loading branch information
erijung authored Nov 27, 2024
1 parent 8eb900e commit acd1651
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/transformers/models/whisper/generation_whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ def _extract_token_timestamps(self, generate_outputs, alignment_heads, time_prec
# since jump_times is only extended in the next step, take index_ and not (index_ + 1)
next_element = jump_times[index_] if index_ < len(jump_times) else round((time_indices[-1] * time_precision), 4)
jump_times.insert(index_, next_element)
timestamps[batch_idx, 1:] = torch.tensor(jump_times)
# print("SURPRISE:", timestamps.shape, batch_idx, torch.tensor(jump_times).shape)
if timestamps.shape[-1] == len(jump_times):
timestamps[batch_idx, 0:] = torch.tensor(jump_times)
else:
timestamps[batch_idx, 1:] = torch.tensor(jump_times)

return timestamps

Expand Down

0 comments on commit acd1651

Please sign in to comment.