Skip to content

Commit acd1651

Browse files
authored
Fix timestamp jumptimes indexOutofBoundsError based on Issue in original repo huggingface#12
1 parent 8eb900e commit acd1651

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/transformers/models/whisper/generation_whisper.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ def _extract_token_timestamps(self, generate_outputs, alignment_heads, time_prec
313313
# since jump_times is only extended in the next step, take index_ and not (index_ + 1)
314314
next_element = jump_times[index_] if index_ < len(jump_times) else round((time_indices[-1] * time_precision), 4)
315315
jump_times.insert(index_, next_element)
316-
timestamps[batch_idx, 1:] = torch.tensor(jump_times)
316+
# print("SURPRISE:", timestamps.shape, batch_idx, torch.tensor(jump_times).shape)
317+
if timestamps.shape[-1] == len(jump_times):
318+
timestamps[batch_idx, 0:] = torch.tensor(jump_times)
319+
else:
320+
timestamps[batch_idx, 1:] = torch.tensor(jump_times)
317321

318322
return timestamps
319323

0 commit comments

Comments
 (0)