examples: fix 03a-image-local
This commit is contained in:
@@ -5,26 +5,29 @@ import os
|
|||||||
|
|
||||||
import tkinter as tk
|
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.services.fal_ai_services import FalImageGenService
|
||||||
from dailyai.transports.local_transport import LocalTransport
|
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")
|
logging.basicConfig(format=f"%(levelno)s %(asctime)s %(message)s")
|
||||||
logger = logging.getLogger("dailyai")
|
logger = logging.getLogger("dailyai")
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
local_joined = False
|
|
||||||
participant_joined = False
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
meeting_duration_minutes = 2
|
meeting_duration_minutes = 2
|
||||||
|
|
||||||
tk_root = tk.Tk()
|
tk_root = tk.Tk()
|
||||||
tk_root.title("Calendar")
|
tk_root.title("dailyai")
|
||||||
|
|
||||||
transport = LocalTransport(
|
transport = LocalTransport(
|
||||||
tk_root=tk_root,
|
tk_root=tk_root,
|
||||||
mic_enabled=True,
|
mic_enabled=False,
|
||||||
camera_enabled=True,
|
camera_enabled=True,
|
||||||
camera_width=1024,
|
camera_width=1024,
|
||||||
camera_height=1024,
|
camera_height=1024,
|
||||||
@@ -32,15 +35,14 @@ async def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
imagegen = FalImageGenService(
|
imagegen = FalImageGenService(
|
||||||
image_size="1024x1024",
|
image_size="square_hd",
|
||||||
aiohttp_session=session,
|
aiohttp_session=session,
|
||||||
key_id=os.getenv("FAL_KEY_ID"),
|
key_id=os.getenv("FAL_KEY_ID"),
|
||||||
key_secret=os.getenv("FAL_KEY_SECRET"),
|
key_secret=os.getenv("FAL_KEY_SECRET"),
|
||||||
)
|
)
|
||||||
image_task = asyncio.create_task(
|
|
||||||
imagegen.run_to_queue(
|
pipeline = Pipeline([imagegen])
|
||||||
transport.send_queue, [
|
await pipeline.queue_frames([TextFrame("a cat in the style of picasso")])
|
||||||
TextFrame("a cat in the style of picasso")]))
|
|
||||||
|
|
||||||
async def run_tk():
|
async def run_tk():
|
||||||
while not transport._stop_threads.is_set():
|
while not transport._stop_threads.is_set():
|
||||||
@@ -48,7 +50,7 @@ async def main():
|
|||||||
tk_root.update_idletasks()
|
tk_root.update_idletasks()
|
||||||
await asyncio.sleep(0.1)
|
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__":
|
if __name__ == "__main__":
|
||||||
@@ -4,9 +4,6 @@ import io
|
|||||||
import os
|
import os
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from dailyai.services.ai_services import ImageGenService
|
|
||||||
|
|
||||||
|
|
||||||
from dailyai.services.ai_services import ImageGenService
|
from dailyai.services.ai_services import ImageGenService
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import signal
|
|||||||
import threading
|
import threading
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from enum import Enum
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ class ThreadedTransport(AbstractTransport):
|
|||||||
pipeline.set_sink(self.send_queue)
|
pipeline.set_sink(self.send_queue)
|
||||||
source_queue = asyncio.Queue()
|
source_queue = asyncio.Queue()
|
||||||
pipeline.set_source(source_queue)
|
pipeline.set_source(source_queue)
|
||||||
pipeline.set_sink(self.send_queue)
|
|
||||||
pipeline_task = asyncio.create_task(pipeline.run_pipeline())
|
pipeline_task = asyncio.create_task(pipeline.run_pipeline())
|
||||||
|
|
||||||
async def yield_frame(frame: Frame) -> AsyncGenerator[Frame, None]:
|
async def yield_frame(frame: Frame) -> AsyncGenerator[Frame, None]:
|
||||||
|
|||||||
Reference in New Issue
Block a user