From 67fac2a4ce8d9063f2e112f6caeafa98710ee50f Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Tue, 18 Apr 2023 18:58:22 +0800 Subject: [PATCH] Check multiple prompts --- whisper/transcribe.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/whisper/transcribe.py b/whisper/transcribe.py index 97bb2d6..a963930 100644 --- a/whisper/transcribe.py +++ b/whisper/transcribe.py @@ -363,7 +363,8 @@ def transcribe( for i, segment in enumerate(current_segments, start=len(all_segments)): if not segment['text'].strip(): continue - if len(all_prompts_segments) > 0 and all_prompts_segments[-1]['text'].strip() == segment['text'].strip(): + check_prompt_num = 1 + if any([prev['text'].strip() == segment['text'].strip() for prev in all_prompts_segments[-check_prompt_num:]]): continue all_prompts_tokens.extend(segment['tokens']) all_prompts_segments.append({"id": i, **segment})