Fix up other examples
This commit is contained in:
@@ -32,8 +32,8 @@ class FalImageGenService(ImageGenService):
|
||||
async def run_image_gen(self, sentence) -> tuple[str, bytes]:
|
||||
def get_image_url(sentence, size):
|
||||
handler = fal.apps.submit(
|
||||
# "110602490-fast-sdxl",
|
||||
"fal-ai/fast-sdxl",
|
||||
"110602490-fast-sdxl",
|
||||
#"fal-ai/fast-sdxl",
|
||||
arguments={"prompt": sentence},
|
||||
)
|
||||
for event in handler.iter_events():
|
||||
|
||||
@@ -28,21 +28,32 @@ async def main(room_url):
|
||||
voice_id=os.getenv("ELEVENLABS_VOICE_ID"),
|
||||
)
|
||||
|
||||
other_joined_event = asyncio.Event()
|
||||
participant_name = ''
|
||||
|
||||
async def say_hello():
|
||||
nonlocal tts
|
||||
nonlocal participant_name
|
||||
|
||||
await other_joined_event.wait()
|
||||
print("done waiting")
|
||||
await tts.say(
|
||||
"Hello there, " + participant_name + "!",
|
||||
transport.send_queue,
|
||||
)
|
||||
await transport.stop_when_done()
|
||||
|
||||
# Register an event handler so we can play the audio when the participant joins.
|
||||
@transport.event_handler("on_participant_joined")
|
||||
async def on_participant_joined(transport, participant):
|
||||
if participant["info"]["isLocal"]:
|
||||
return
|
||||
|
||||
await tts.say(
|
||||
"Hello there, " + participant["info"]["userName"] + "!",
|
||||
transport.send_queue,
|
||||
)
|
||||
nonlocal participant_name
|
||||
participant_name = participant["info"]["userName"] or ''
|
||||
other_joined_event.set()
|
||||
|
||||
# wait for the output queue to be empty, then leave the meeting
|
||||
await transport.stop_when_done()
|
||||
|
||||
await transport.run()
|
||||
await asyncio.gather(transport.run(), say_hello())
|
||||
del tts
|
||||
|
||||
|
||||
|
||||
@@ -47,8 +47,7 @@ async def main(room_url):
|
||||
await other_joined_event.wait()
|
||||
await tts.run_to_queue(
|
||||
transport.send_queue,
|
||||
llm.run([LLMMessagesQueueFrame(messages)]),
|
||||
add_end_of_stream=True
|
||||
llm.run([LLMMessagesQueueFrame(messages)])
|
||||
)
|
||||
await transport.stop_when_done()
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ async def main(room_url):
|
||||
camera_enabled=True,
|
||||
camera_width=1024,
|
||||
camera_height=1024,
|
||||
duration_minutes=1
|
||||
)
|
||||
|
||||
imagegen = FalImageGenService(
|
||||
@@ -32,13 +33,19 @@ async def main(room_url):
|
||||
key_secret=os.getenv("FAL_KEY_SECRET"),
|
||||
)
|
||||
|
||||
@transport.event_handler("on_first_other_participant_joined")
|
||||
async def on_first_other_participant_joined(transport):
|
||||
other_joined_event = asyncio.Event()
|
||||
|
||||
async def show_image():
|
||||
await other_joined_event.wait()
|
||||
await imagegen.run_to_queue(
|
||||
transport.send_queue, [TextFrame("a cat in the style of picasso")]
|
||||
)
|
||||
|
||||
await transport.run()
|
||||
@transport.event_handler("on_first_other_participant_joined")
|
||||
async def on_first_other_participant_joined(transport):
|
||||
other_joined_event.set()
|
||||
|
||||
await asyncio.gather(transport.run(), show_image())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -62,8 +62,15 @@ async def main(room_url: str):
|
||||
await source_queue.put(EndFrame())
|
||||
pipeline_run_task = pipeline.run_pipeline()
|
||||
|
||||
other_participant_joined = asyncio.Event()
|
||||
|
||||
@transport.event_handler("on_first_other_participant_joined")
|
||||
async def on_first_other_participant_joined(transport):
|
||||
other_participant_joined.set()
|
||||
|
||||
async def say_something():
|
||||
await other_participant_joined.wait()
|
||||
|
||||
await azure_tts.say(
|
||||
"My friend the LLM is now going to tell a joke about llamas.",
|
||||
transport.send_queue,
|
||||
@@ -87,9 +94,8 @@ async def main(room_url: str):
|
||||
break
|
||||
|
||||
await asyncio.gather(pipeline_run_task, buffer_to_send_queue())
|
||||
await transport.stop_when_done()
|
||||
|
||||
await transport.run()
|
||||
await asyncio.gather(transport.run(), say_something())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -140,12 +140,18 @@ async def main(room_url):
|
||||
)
|
||||
pipeline_task = pipeline.run_pipeline()
|
||||
|
||||
other_joined = asyncio.Event()
|
||||
|
||||
@transport.event_handler("on_first_other_participant_joined")
|
||||
async def on_first_other_participant_joined(transport):
|
||||
other_joined.set()
|
||||
|
||||
async def show_calendar():
|
||||
await other_joined.wait()
|
||||
await pipeline_task
|
||||
await transport.stop_when_done()
|
||||
|
||||
await transport.run()
|
||||
await asyncio.gather(transport.run(), show_calendar())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -49,7 +49,7 @@ async def main(room_url: str, token):
|
||||
async def on_first_other_participant_joined(transport):
|
||||
await tts.say("Hi, I'm listening!", transport.send_queue)
|
||||
|
||||
async def handle_transcriptions():
|
||||
async def have_conversation():
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
@@ -75,7 +75,7 @@ async def main(room_url: str, token):
|
||||
|
||||
transport.transcription_settings["extra"]["endpointing"] = True
|
||||
transport.transcription_settings["extra"]["punctuate"] = True
|
||||
await asyncio.gather(transport.run(), handle_transcriptions())
|
||||
await asyncio.gather(transport.run(), have_conversation())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user