Exit meeting after saying something for samples 1 and 2

This commit is contained in:
Moishe Lettvin
2024-01-09 06:05:24 -05:00
parent 11a553240f
commit 534a4e2fa1
3 changed files with 18 additions and 0 deletions

View File

@@ -261,6 +261,7 @@ class DailyTransportService(EventHandler):
for frame in frames:
if frame.frame_type == FrameType.END_STREAM:
self.logger.info("Stopping frame consumer thread")
self.output_queue.task_done()
return
# if interrupted, we just pull frames off the queue and discard them

View File

@@ -39,6 +39,13 @@ async def main(room_url):
async for audio in audio_generator:
transport.output_queue.put(OutputQueueFrame(FrameType.AUDIO_FRAME, audio))
# Put an "end stream" item on the queue, which will cause it to shut down when it's processed
# all the audio.
transport.output_queue.put(OutputQueueFrame(FrameType.END_STREAM, None))
transport.output_queue.join()
transport.stop()
await transport.run()

View File

@@ -32,6 +32,9 @@ async def main(room_url):
@transport.event_handler("on_participant_joined")
async def on_participant_joined(transport, participant):
if participant["id"] == transport.my_participant_id:
return
current_text = ""
async for text in llm_generator:
current_text += text
@@ -40,6 +43,13 @@ async def main(room_url):
transport.output_queue.put(OutputQueueFrame(FrameType.AUDIO_FRAME, audio))
current_text = ""
# Put an "end stream" item on the queue, which will cause it to shut down when it's processed
# all the audio.
transport.output_queue.put(OutputQueueFrame(FrameType.END_STREAM, None))
transport.output_queue.join()
transport.stop()
await transport.run()