Skip to content

Commit

Permalink
Fix hallucinations with no_speech_thres
Browse files Browse the repository at this point in the history
Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
  • Loading branch information
makaveli10 committed Aug 8, 2024
1 parent aade677 commit fac62aa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions whisper_live/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ def speech_to_text(self):

input_bytes, duration = self.get_audio_chunk_for_processing()
if duration < 1.0:
time.sleep(0.1) # wait for audio chunks to arrive
continue
try:
input_sample = input_bytes.copy()
Expand Down Expand Up @@ -1046,12 +1047,14 @@ def update_segments(self, segments, duration):
self.transcript.append(self.format_segment(start, end, text_))
offset = min(duration, s.end)

self.current_out += segments[-1].text
last_segment = self.format_segment(
self.timestamp_offset + segments[-1].start,
self.timestamp_offset + min(duration, segments[-1].end),
self.current_out
)
# 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
last_segment = self.format_segment(
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
# and append the segment to the list
Expand Down

1 comment on commit fac62aa

@sirius911
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good morning,
It seems that the last_segment variable may not have a value in the ServeClientFasterWhisper.update_segments() method
Sincerely

Please sign in to comment.