Przeglądaj źródła

fix condition_on_previous_text (#1224)

prompt_reset_since is set before all_tokens is extended hence does not have the expected effect.
Valentin Berkes 1 rok temu
rodzic
commit
248b6cb124
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      whisper/transcribe.py

+ 4 - 4
whisper/transcribe.py

@@ -312,10 +312,6 @@ def transcribe(
                 )
                 seek += segment_size
 
-            if not condition_on_previous_text or result.temperature > 0.5:
-                # do not feed the prompt tokens if a high temperature was used
-                prompt_reset_since = len(all_tokens)
-
             if word_timestamps:
                 add_word_timestamps(
                     segments=current_segments,
@@ -361,6 +357,10 @@ def transcribe(
                 [token for segment in current_segments for token in segment["tokens"]]
             )
 
+            if not condition_on_previous_text or result.temperature > 0.5:
+                # do not feed the prompt tokens if a high temperature was used
+                prompt_reset_since = len(all_tokens)
+
             # update progress bar
             pbar.update(min(content_frames, seek) - previous_seek)