From 81086f6d33675c390bc385e2f9e5b1aa975db579 Mon Sep 17 00:00:00 2001 From: Guillaume Klein Date: Tue, 12 Sep 2023 14:44:37 +0200 Subject: [PATCH] Always run the encoder at the beginning of the loop (#468) --- faster_whisper/transcribe.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/faster_whisper/transcribe.py b/faster_whisper/transcribe.py index 717cb59..dd01b80 100644 --- a/faster_whisper/transcribe.py +++ b/faster_whisper/transcribe.py @@ -417,7 +417,7 @@ class WhisperModel: prefix=options.prefix if seek == 0 else None, ) - if encoder_output is None: + if seek > 0 or encoder_output is None: encoder_output = self.encode(segment) ( @@ -447,7 +447,6 @@ class WhisperModel: # fast-forward to the next segment boundary seek += segment_size - encoder_output = None continue tokens = result.sequences_ids[0] @@ -554,8 +553,6 @@ class WhisperModel: if seek_shift > 0: seek = previous_seek + seek_shift - encoder_output = None - for segment in current_segments: tokens = segment["tokens"] text = tokenizer.decode(tokens)