Fix hallucinations with no_speech_thres

Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
This commit is contained in:
makaveli10
2024-08-08 06:05:12 -04:00
parent aade67736a
commit fac62aaccc
+3
View File
@@ -973,6 +973,7 @@ class ServeClientFasterWhisper(ServeClientBase):
input_bytes, duration = self.get_audio_chunk_for_processing() input_bytes, duration = self.get_audio_chunk_for_processing()
if duration < 1.0: if duration < 1.0:
time.sleep(0.1) # wait for audio chunks to arrive
continue continue
try: try:
input_sample = input_bytes.copy() input_sample = input_bytes.copy()
@@ -1046,6 +1047,8 @@ class ServeClientFasterWhisper(ServeClientBase):
self.transcript.append(self.format_segment(start, end, text_)) self.transcript.append(self.format_segment(start, end, text_))
offset = min(duration, s.end) offset = min(duration, s.end)
# only process the segments if it satisfies the no_speech_thresh
if segments[-1].no_speech_prob <= self.no_speech_thresh:
self.current_out += segments[-1].text self.current_out += segments[-1].text
last_segment = self.format_segment( last_segment = self.format_segment(
self.timestamp_offset + segments[-1].start, self.timestamp_offset + segments[-1].start,