makaveli10 commited on
Commit
795e5f6
1 Parent(s): 855f306

fix: end of segment

Browse files
Files changed (1) hide show
  1. whisper_live/trt_server.py +5 -5
whisper_live/trt_server.py CHANGED
@@ -139,13 +139,13 @@ class TranscriptionServer:
139
  speech_prob = self.vad_model(torch.from_numpy(frame_np.copy()), self.RATE).item()
140
  if speech_prob < self.vad_threshold:
141
  no_voice_activity_chunks += 1
142
- if no_voice_activity_chunks > 2:
143
  if not self.clients[websocket].eos:
144
  self.clients[websocket].set_eos(True)
145
  time.sleep(0.1) # EOS stop receiving frames for a 100ms(to send output to LLM.)
146
  continue
147
  no_voice_activity_chunks = 0
148
- # self.clients[websocket].set_eos(False)
149
 
150
  except Exception as e:
151
  logging.error(e)
@@ -391,13 +391,13 @@ class ServeClient:
391
  "eos": self.eos
392
  })
393
  )
 
394
  if self.eos:
395
  # self.append_segment(last_segment)
396
  self.timestamp_offset += duration
397
  self.prompt = ' '.join(segment['text'] for segment in segments)
398
  self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
399
- self.set_eos(False)
400
-
401
  logging.info(f"[INFO:] Processed : {self.timestamp_offset} seconds / {self.frames_np.shape[0] / self.RATE} seconds"
402
  )
403
 
@@ -435,4 +435,4 @@ class ServeClient:
435
  """
436
  logging.info("Cleaning up.")
437
  self.exit = True
438
- self.transcriber.destroy()
 
139
  speech_prob = self.vad_model(torch.from_numpy(frame_np.copy()), self.RATE).item()
140
  if speech_prob < self.vad_threshold:
141
  no_voice_activity_chunks += 1
142
+ if no_voice_activity_chunks > 3:
143
  if not self.clients[websocket].eos:
144
  self.clients[websocket].set_eos(True)
145
  time.sleep(0.1) # EOS stop receiving frames for a 100ms(to send output to LLM.)
146
  continue
147
  no_voice_activity_chunks = 0
148
+ self.clients[websocket].set_eos(False)
149
 
150
  except Exception as e:
151
  logging.error(e)
 
391
  "eos": self.eos
392
  })
393
  )
394
+ logging.info(f"[INFO]: {segments}, eos: {self.eos}")
395
  if self.eos:
396
  # self.append_segment(last_segment)
397
  self.timestamp_offset += duration
398
  self.prompt = ' '.join(segment['text'] for segment in segments)
399
  self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
400
+ # self.set_eos(False)
 
401
  logging.info(f"[INFO:] Processed : {self.timestamp_offset} seconds / {self.frames_np.shape[0] / self.RATE} seconds"
402
  )
403
 
 
435
  """
436
  logging.info("Cleaning up.")
437
  self.exit = True
438
+ # self.transcriber.destroy()