Spaces:
Paused
Paused
Commit
·
94498e7
1
Parent(s):
456c9bb
update server.py
Browse files
whisper_live/trt_server.py
CHANGED
@@ -142,10 +142,10 @@ class TranscriptionServer:
|
|
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.
|
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)
|
@@ -360,7 +360,7 @@ class ServeClient:
|
|
360 |
break
|
361 |
|
362 |
if self.frames_np is None:
|
363 |
-
time.sleep(0.
|
364 |
continue
|
365 |
|
366 |
# clip audio if the current chunk exceeds 30 seconds, this basically implies that
|
@@ -384,7 +384,6 @@ class ServeClient:
|
|
384 |
if len(last_segment):
|
385 |
segments.append({"text": last_segment})
|
386 |
try:
|
387 |
-
print(f"Sending... {segments}")
|
388 |
self.websocket.send(
|
389 |
json.dumps({
|
390 |
"uid": self.client_uid,
|
@@ -399,9 +398,7 @@ class ServeClient:
|
|
399 |
self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
|
400 |
self.set_eos(False)
|
401 |
|
402 |
-
logging.info(
|
403 |
-
f"[INFO:] \
|
404 |
-
Processed : {self.timestamp_offset} seconds / {self.frames_np.shape[0] / self.RATE} seconds"
|
405 |
)
|
406 |
|
407 |
except Exception as e:
|
|
|
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)
|
|
|
360 |
break
|
361 |
|
362 |
if self.frames_np is None:
|
363 |
+
time.sleep(0.02) # wait for any audio to arrive
|
364 |
continue
|
365 |
|
366 |
# clip audio if the current chunk exceeds 30 seconds, this basically implies that
|
|
|
384 |
if len(last_segment):
|
385 |
segments.append({"text": last_segment})
|
386 |
try:
|
|
|
387 |
self.websocket.send(
|
388 |
json.dumps({
|
389 |
"uid": self.client_uid,
|
|
|
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 |
|
404 |
except Exception as e:
|