Skip to content

Commit

Permalink
small code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Gldkslfmsd committed Aug 19, 2024
1 parent e4f0cfb commit 73904ef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions whisper_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ def clear_buffer(self):

def insert_audio_chunk(self, audio):
res = self.vac(audio)
print(res)
self.audio_buffer = np.append(self.audio_buffer, audio)

if res is not None:
Expand All @@ -584,11 +583,10 @@ def insert_audio_chunk(self, audio):
if self.status == 'voice':
self.online.insert_audio_chunk(self.audio_buffer)
self.current_online_chunk_buffer_size += len(self.audio_buffer)
if self.status is not None:
self.clear_buffer()
else: # we are at the beginning of process, no voice has ever been detected
# We keep the 1s because VAD may later find start of voice in it.
# But trimming it to prevent OOM.
else:
# We keep 1 second because VAD may later find start of voice in it.
# But we trim it to prevent OOM.
self.buffer_offset += max(0,len(self.audio_buffer)-self.SAMPLING_RATE)
self.audio_buffer = self.audio_buffer[-self.SAMPLING_RATE:]

Expand Down

0 comments on commit 73904ef

Please sign in to comment.