Skip to content

Commit

Permalink
examples: fix 03a-image-local
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Apr 4, 2024
1 parent d687c8c commit 1ea503c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,52 @@

import tkinter as tk

from dailyai.pipeline.frames import TextFrame
from dailyai.pipeline.frames import TextFrame, EndFrame
from dailyai.pipeline.pipeline import Pipeline
from dailyai.services.fal_ai_services import FalImageGenService
from dailyai.transports.local_transport import LocalTransport

from dotenv import load_dotenv
load_dotenv(override=True)

logging.basicConfig(format=f"%(levelno)s %(asctime)s %(message)s")
logger = logging.getLogger("dailyai")
logger.setLevel(logging.DEBUG)

local_joined = False
participant_joined = False


async def main():
async with aiohttp.ClientSession() as session:
meeting_duration_minutes = 2

tk_root = tk.Tk()
tk_root.title("Calendar")
tk_root.title("dailyai")

transport = LocalTransport(
tk_root=tk_root,
mic_enabled=True,
mic_enabled=False,
camera_enabled=True,
camera_width=1024,
camera_height=1024,
duration_minutes=meeting_duration_minutes,
)

imagegen = FalImageGenService(
image_size="1024x1024",
image_size="square_hd",
aiohttp_session=session,
key_id=os.getenv("FAL_KEY_ID"),
key_secret=os.getenv("FAL_KEY_SECRET"),
)
image_task = asyncio.create_task(
imagegen.run_to_queue(
transport.send_queue, [
TextFrame("a cat in the style of picasso")]))

pipeline = Pipeline([imagegen])
await pipeline.queue_frames([TextFrame("a cat in the style of picasso")])

async def run_tk():
while not transport._stop_threads.is_set():
tk_root.update()
tk_root.update_idletasks()
await asyncio.sleep(0.1)

await asyncio.gather(transport.run(), image_task, run_tk())
await asyncio.gather(transport.run(pipeline, override_pipeline_source_queue=False), run_tk())


if __name__ == "__main__":
Expand Down
3 changes: 0 additions & 3 deletions src/dailyai/services/fal_ai_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import os
from PIL import Image

from dailyai.services.ai_services import ImageGenService


from dailyai.services.ai_services import ImageGenService

try:
Expand Down
1 change: 0 additions & 1 deletion src/dailyai/transports/daily_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import threading
import types

from enum import Enum
from functools import partial
from typing import Any

Expand Down
1 change: 0 additions & 1 deletion src/dailyai/transports/threaded_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ async def run_interruptible_pipeline(
pipeline.set_sink(self.send_queue)
source_queue = asyncio.Queue()
pipeline.set_source(source_queue)
pipeline.set_sink(self.send_queue)
pipeline_task = asyncio.create_task(pipeline.run_pipeline())

async def yield_frame(frame: Frame) -> AsyncGenerator[Frame, None]:
Expand Down

0 comments on commit 1ea503c

Please sign in to comment.