Skip to content

Commit

Permalink
Don't update duration if last timestamp is same as begin (openai#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
vickianand committed Sep 29, 2022
1 parent 62fe7f1 commit 2b0c297
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def add_segment(
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
Expand Down

0 comments on commit 2b0c297

Please sign in to comment.