simplify the join, no need for END_STREAM
This commit is contained in:
@@ -39,11 +39,8 @@ async def main(room_url):
|
|||||||
async for audio in audio_generator:
|
async for audio in audio_generator:
|
||||||
transport.output_queue.put(OutputQueueFrame(FrameType.AUDIO_FRAME, audio))
|
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
|
# wait for the output queue to be empty, then leave the meeting
|
||||||
# all the audio.
|
|
||||||
transport.output_queue.put(OutputQueueFrame(FrameType.END_STREAM, None))
|
|
||||||
transport.output_queue.join()
|
transport.output_queue.join()
|
||||||
|
|
||||||
transport.stop()
|
transport.stop()
|
||||||
|
|
||||||
await transport.run()
|
await transport.run()
|
||||||
|
|||||||
@@ -43,11 +43,8 @@ async def main(room_url):
|
|||||||
transport.output_queue.put(OutputQueueFrame(FrameType.AUDIO_FRAME, audio))
|
transport.output_queue.put(OutputQueueFrame(FrameType.AUDIO_FRAME, audio))
|
||||||
current_text = ""
|
current_text = ""
|
||||||
|
|
||||||
# Put an "end stream" item on the queue, which will cause it to shut down when it's processed
|
# wait for the output queue to be empty, then leave the meeting
|
||||||
# all the audio.
|
|
||||||
transport.output_queue.put(OutputQueueFrame(FrameType.END_STREAM, None))
|
|
||||||
transport.output_queue.join()
|
transport.output_queue.join()
|
||||||
|
|
||||||
transport.stop()
|
transport.stop()
|
||||||
|
|
||||||
await transport.run()
|
await transport.run()
|
||||||
|
|||||||
43
src/samples/theoretical-to-real/04-utterance-and-speech.py
Normal file
43
src/samples/theoretical-to-real/04-utterance-and-speech.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import argparse
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from dailyai.output_queue import OutputQueueFrame, FrameType
|
||||||
|
from dailyai.services.daily_transport_service import DailyTransportService
|
||||||
|
from dailyai.services.open_ai_services import OpenAIImageGenService
|
||||||
|
|
||||||
|
local_joined = False
|
||||||
|
participant_joined = False
|
||||||
|
|
||||||
|
async def main(room_url):
|
||||||
|
meeting_duration_minutes = 1
|
||||||
|
transport = DailyTransportService(
|
||||||
|
room_url,
|
||||||
|
None,
|
||||||
|
"Show a still frame image",
|
||||||
|
meeting_duration_minutes,
|
||||||
|
)
|
||||||
|
transport.mic_enabled = False
|
||||||
|
transport.camera_enabled = True
|
||||||
|
transport.camera_width = 1024
|
||||||
|
transport.camera_height = 1024
|
||||||
|
|
||||||
|
imagegen = OpenAIImageGenService()
|
||||||
|
image_task = asyncio.create_task(imagegen.run_image_gen("a cat in the style of picasso", "1024x1024"))
|
||||||
|
|
||||||
|
@transport.event_handler("on_participant_joined")
|
||||||
|
async def on_participant_joined(transport, participant):
|
||||||
|
(_, image_bytes) = await image_task
|
||||||
|
transport.output_queue.put(OutputQueueFrame(FrameType.IMAGE_FRAME, image_bytes))
|
||||||
|
|
||||||
|
await transport.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="Simple Daily Bot Sample")
|
||||||
|
parser.add_argument(
|
||||||
|
"-u", "--url", type=str, required=True, help="URL of the Daily room to join"
|
||||||
|
)
|
||||||
|
|
||||||
|
args: argparse.Namespace = parser.parse_args()
|
||||||
|
|
||||||
|
asyncio.run(main(args.url))
|
||||||
Reference in New Issue
Block a user