|
|
@@ -32,6 +32,7 @@ class STTSink(voice_recv.AudioSink):
|
|
|
self.responding = False
|
|
|
self.last_stt_seconds = None
|
|
|
self.last_reply_seconds = None
|
|
|
+ self.last_voice = 0.0
|
|
|
self.last_error = 0
|
|
|
self.stats_lock = threading.Lock()
|
|
|
self.stats = Counter(audio=0, rtcp=0, pcm=0, audible=0, phrases=0, stt=0)
|
|
|
@@ -135,6 +136,7 @@ class STTSink(voice_recv.AudioSink):
|
|
|
buffer[1].extend(pcm[:available])
|
|
|
if audible:
|
|
|
buffer[2] = now
|
|
|
+ self.last_voice = now
|
|
|
|
|
|
async def flush_phrases(self):
|
|
|
while True:
|
|
|
@@ -211,6 +213,17 @@ class STTSink(voice_recv.AudioSink):
|
|
|
async def respond_batches(self):
|
|
|
while not self.closed:
|
|
|
await self.pending_event.wait()
|
|
|
+ # L'affichage STT continue ; seule la réponse attend le silence global.
|
|
|
+ while not self.closed:
|
|
|
+ await self.queue.join()
|
|
|
+ with self.lock:
|
|
|
+ quiet = time.monotonic() - self.last_voice > 2.0
|
|
|
+ buffered = bool(self.buffers)
|
|
|
+ if quiet and not buffered and self.queue.empty():
|
|
|
+ break
|
|
|
+ await asyncio.sleep(0.1)
|
|
|
+ if self.closed:
|
|
|
+ return
|
|
|
self.pending_event.clear()
|
|
|
batch, self.pending = self.pending, []
|
|
|
if not batch:
|