Spaces:
Paused
Paused
makaveli10
commited on
Commit
•
81cb63c
1
Parent(s):
71a8e88
send LLM output only once after eos=true
Browse files- whisper_live/trt_server.py +23 -19
whisper_live/trt_server.py
CHANGED
@@ -350,13 +350,16 @@ class ServeClient:
|
|
350 |
|
351 |
"""
|
352 |
while True:
|
353 |
-
|
354 |
-
|
355 |
-
llm_output =
|
356 |
-
if
|
357 |
-
self.
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
360 |
|
361 |
if self.exit:
|
362 |
logging.info("Exiting speech to text thread")
|
@@ -387,18 +390,21 @@ class ServeClient:
|
|
387 |
if len(last_segment):
|
388 |
segments.append({"text": last_segment})
|
389 |
try:
|
390 |
-
self.
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
|
|
|
|
|
|
398 |
if self.eos:
|
399 |
# self.append_segment(last_segment)
|
400 |
self.timestamp_offset += duration
|
401 |
-
|
402 |
if self.last_prompt != self.prompt:
|
403 |
self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
|
404 |
|
@@ -406,9 +412,7 @@ class ServeClient:
|
|
406 |
# self.set_eos(False)
|
407 |
logging.info(f"[INFO:] Processed : {self.timestamp_offset} seconds / {self.frames_np.shape[0] / self.RATE} seconds"
|
408 |
)
|
409 |
-
else:
|
410 |
-
self.prompt = ' '.join(segment['text'] for segment in segments)
|
411 |
-
|
412 |
if self.last_prompt != self.prompt:
|
413 |
self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
|
414 |
|
|
|
350 |
|
351 |
"""
|
352 |
while True:
|
353 |
+
if self.eos:
|
354 |
+
try:
|
355 |
+
llm_output = None
|
356 |
+
if self.llm_queue is not None:
|
357 |
+
while not self.llm_queue.empty():
|
358 |
+
llm_output = self.llm_queue.get_nowait()
|
359 |
+
if llm_output:
|
360 |
+
self.websocket.send(json.dumps(llm_output))
|
361 |
+
except queue.Empty:
|
362 |
+
pass
|
363 |
|
364 |
if self.exit:
|
365 |
logging.info("Exiting speech to text thread")
|
|
|
390 |
if len(last_segment):
|
391 |
segments.append({"text": last_segment})
|
392 |
try:
|
393 |
+
self.prompt = ' '.join(segment['text'] for segment in segments)
|
394 |
+
if self.last_prompt != self.prompt:
|
395 |
+
self.websocket.send(
|
396 |
+
json.dumps({
|
397 |
+
"uid": self.client_uid,
|
398 |
+
"segments": segments,
|
399 |
+
"eos": self.eos
|
400 |
+
})
|
401 |
+
)
|
402 |
+
logging.info(f"[INFO]: {segments}, eos: {self.eos}")
|
403 |
+
|
404 |
if self.eos:
|
405 |
# self.append_segment(last_segment)
|
406 |
self.timestamp_offset += duration
|
407 |
+
|
408 |
if self.last_prompt != self.prompt:
|
409 |
self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
|
410 |
|
|
|
412 |
# self.set_eos(False)
|
413 |
logging.info(f"[INFO:] Processed : {self.timestamp_offset} seconds / {self.frames_np.shape[0] / self.RATE} seconds"
|
414 |
)
|
415 |
+
else:
|
|
|
|
|
416 |
if self.last_prompt != self.prompt:
|
417 |
self.transcription_queue.put({"uid": self.client_uid, "prompt": self.prompt})
|
418 |
|