File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 136136 for segment in segments :
137137 if info .language in ["ja" ] and not args .translate :
138138 segment .text = segment .text .replace (" " , "" ) # Remove additional spaces
139- print (f" { segment .start } --> { segment .end } { segment .text } " )
140- if prev_segment == segment .text :
139+
140+ text = " " .join (segment .text .strip ().split ()) # NEW
141+ print (f" { segment .start } --> { segment .end } { text } " )
142+
143+ if prev_segment == text :
141144 count_duplicates += 1
142145 else :
143146 count_duplicates = 0
144- if count_duplicates > 3 :
145- print (" Whisper hallucinating with too many duplicates" )
146- sys .exit (- 1 )
147- prev_segment = segment .text
147+
148+ if count_duplicates > 10 :
149+ print ("Possible hallucination detected. Skipping segment." )
150+ continue
151+
152+ prev_segment = text
153+ segment .text = text # CLEAN VERSION
148154 #if WORD_TIMESTAMPS:
149155 # for word in segment.words:
150156 # print(f" [{round(word.start, 2)} -> {round(word.end, 2)}] {word.word}")
You can’t perform that action at this time.
0 commit comments