From 2b0c2971af0ad616ffca0e0df5324b4ce5152914 Mon Sep 17 00:00:00 2001 From: Vicki Anand Date: Thu, 29 Sep 2022 15:27:48 -0400 Subject: [PATCH] Don't update duration if last timestamp is same as begin (#191) --- whisper/transcribe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisper/transcribe.py b/whisper/transcribe.py index 195ea2e..2623613 100644 --- a/whisper/transcribe.py +++ b/whisper/transcribe.py @@ -220,7 +220,7 @@ def transcribe( else: duration = segment_duration timestamps = tokens[timestamp_tokens.nonzero().flatten()] - if len(timestamps) > 0: + if len(timestamps) > 0 and timestamps[-1].item() != tokenizer.timestamp_begin: # no consecutive timestamps but it has a timestamp; use the last one. # single timestamp at the end means no speech after the last timestamp. last_timestamp_position = timestamps[-1].item() - tokenizer.timestamp_begin