diff --git a/faster_whisper/transcribe.py b/faster_whisper/transcribe.py index f389f09f..d8043fa4 100644 --- a/faster_whisper/transcribe.py +++ b/faster_whisper/transcribe.py @@ -1083,6 +1083,7 @@ def generate_segments( clip_idx = 0 seek = seek_clips[clip_idx][0] all_tokens = [] + all_prompt_text = [] prompt_reset_since = 0 if options.initial_prompt is not None: @@ -1293,7 +1294,13 @@ def next_words_segment(segments: List[dict]) -> Optional[dict]: if segment["start"] == segment["end"] or not text.strip(): continue - all_tokens.extend(tokens) + check_prompt_num = 1 + if all( + text.strip() != i.strip() + for i in all_prompt_text[-check_prompt_num:] + ): + all_tokens.extend(tokens) + all_prompt_text.append(text) idx += 1 yield Segment(