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
+9 -6
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,12 +1047,14 @@ 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)
self.current_out += segments[-1].text # only process the segments if it satisfies the no_speech_thresh
last_segment = self.format_segment( if segments[-1].no_speech_prob <= self.no_speech_thresh:
self.timestamp_offset + segments[-1].start, self.current_out += segments[-1].text
self.timestamp_offset + min(duration, segments[-1].end), last_segment = self.format_segment(
self.current_out self.timestamp_offset + segments[-1].start,
) self.timestamp_offset + min(duration, segments[-1].end),
self.current_out
)
# if same incomplete segment is seen multiple times then update the offset # if same incomplete segment is seen multiple times then update the offset
# and append the segment to the list # and append the segment to the list