Ignore repeated prompt
This commit is contained in:
@@ -330,6 +330,7 @@ class WhisperModel:
|
|||||||
content_frames = features.shape[-1] - self.feature_extractor.nb_max_frames
|
content_frames = features.shape[-1] - self.feature_extractor.nb_max_frames
|
||||||
seek = 0
|
seek = 0
|
||||||
all_tokens = []
|
all_tokens = []
|
||||||
|
all_prompt_text = []
|
||||||
prompt_reset_since = 0
|
prompt_reset_since = 0
|
||||||
|
|
||||||
if options.initial_prompt is not None:
|
if options.initial_prompt is not None:
|
||||||
@@ -501,7 +502,10 @@ class WhisperModel:
|
|||||||
if segment["start"] == segment["end"] or not text.strip():
|
if segment["start"] == segment["end"] or not text.strip():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
check_prompt_num = 1
|
||||||
|
if all([text.strip() != i.strip() for i in all_prompt_text[-check_prompt_num:]]):
|
||||||
all_tokens.extend(tokens)
|
all_tokens.extend(tokens)
|
||||||
|
all_prompt_text.append(text)
|
||||||
|
|
||||||
yield Segment(
|
yield Segment(
|
||||||
start=segment["start"],
|
start=segment["start"],
|
||||||
|
|||||||
Reference in New Issue
Block a user