From 6a72b61564dbea7242b8d4eab74af375df516759 Mon Sep 17 00:00:00 2001 From: m-bain <36994049+m-bain@users.noreply.github.com> Date: Tue, 11 Apr 2023 20:15:37 +0100 Subject: [PATCH] clamp end_timestamp to prevent infinite loop --- whisperx/asr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/whisperx/asr.py b/whisperx/asr.py index ac16459..e78d77c 100644 --- a/whisperx/asr.py +++ b/whisperx/asr.py @@ -269,6 +269,10 @@ def transcribe( end_timestamp_pos = ( sliced_tokens[-1].item() - tokenizer.timestamp_begin ) + + # clamp end-time to at least be 1 frame after start-time + end_timestamp_pos = max(end_timestamp_pos, start_timestamp_pos + time_precision) + current_segments.append( new_segment( start=time_offset + start_timestamp_pos * time_precision, @@ -426,4 +430,4 @@ def transcribe_with_vad( output["language"] = output["segments"][0]["language"] - return output \ No newline at end of file + return output