basic animation kind of works
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import inspect
|
||||
import logging
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import types
|
||||
@@ -59,8 +60,8 @@ class DailyTransportService(EventHandler):
|
||||
self.story_started = False
|
||||
self.mic_enabled = False
|
||||
self.mic_sample_rate = 16000
|
||||
self.camera_width = 1024
|
||||
self.camera_height = 768
|
||||
self.camera_width = 960
|
||||
self.camera_height = 960
|
||||
self.camera_enabled = False
|
||||
|
||||
self.send_queue = asyncio.Queue()
|
||||
@@ -322,9 +323,10 @@ class DailyTransportService(EventHandler):
|
||||
if self.image:
|
||||
self.camera.write_frame(self.image)
|
||||
if self.images:
|
||||
this_frame = self.current_frame % len(self.images)
|
||||
self.camera.write_frame(self.sprites[self.images[this_frame]])
|
||||
self.current_frame = this_frame + 1
|
||||
frame_index = self.current_frame % len(self.images)
|
||||
this_frame = self.images[frame_index]
|
||||
self.camera.write_frame(this_frame)
|
||||
self.current_frame = frame_index + 1
|
||||
|
||||
time.sleep(1.0 / 8) # 8 fps
|
||||
except Exception as e:
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from PIL import Image
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@@ -14,13 +17,33 @@ from dailyai.services.elevenlabs_ai_service import ElevenLabsTTSService
|
||||
from dailyai.services.fal_ai_services import FalImageGenService
|
||||
from dailyai.services.open_ai_services import OpenAIImageGenService
|
||||
from dailyai.queue_aggregators import LLMContextAggregator
|
||||
from dailyai.queue_frame import LLMMessagesQueueFrame, QueueFrame, TextQueueFrame
|
||||
from dailyai.queue_frame import LLMMessagesQueueFrame, QueueFrame, TextQueueFrame, ImageQueueFrame, ImageListQueueFrame
|
||||
from dailyai.services.ai_services import AIService
|
||||
|
||||
from typing import AsyncGenerator, List
|
||||
|
||||
sprites = {}
|
||||
image_files = [
|
||||
'cat1.png',
|
||||
'cat2.png',
|
||||
'cat3.png'
|
||||
]
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
for file in image_files:
|
||||
# Build the full path to the image file
|
||||
full_path = os.path.join(script_dir, "images", file)
|
||||
# Get the filename without the extension to use as the dictionary key
|
||||
filename = os.path.splitext(os.path.basename(full_path))[0]
|
||||
# Open the image and convert it to bytes
|
||||
with Image.open(full_path) as img:
|
||||
sprites[file] = img.tobytes()
|
||||
|
||||
quiet_frame = ImageQueueFrame("", sprites["cat1.png"])
|
||||
sprite_list = list(sprites.values())
|
||||
talking = [random.choice(sprite_list) for x in range(30)]
|
||||
talking_frame = ImageListQueueFrame(images=talking)
|
||||
class TranscriptFilter(AIService):
|
||||
def __init__(self, bot_participant_id=None):
|
||||
self.bot_participant_id = bot_participant_id
|
||||
@@ -67,8 +90,8 @@ async def main(room_url:str, token):
|
||||
transport.mic_enabled = True
|
||||
transport.mic_sample_rate = 16000
|
||||
transport.camera_enabled = True
|
||||
transport.camera_width = 1024
|
||||
transport.camera_height = 1024
|
||||
transport.camera_width = 960
|
||||
transport.camera_height = 960
|
||||
|
||||
llm = AzureLLMService()
|
||||
tts = ElevenLabsTTSService()
|
||||
@@ -107,12 +130,7 @@ async def main(room_url:str, token):
|
||||
)
|
||||
|
||||
async def make_cats():
|
||||
imagegen = OpenAIImageGenService(image_size="1024x1024")
|
||||
|
||||
while True:
|
||||
print("generating new image")
|
||||
await imagegen.run_to_queue(transport.send_queue, [TextQueueFrame("a golden kitty trophy, cartoon, colorful, detailed, 4k")])
|
||||
await asyncio.sleep(10)
|
||||
await transport.send_queue.put(talking_frame)
|
||||
|
||||
transport.transcription_settings["extra"]["punctuate"] = True
|
||||
await asyncio.gather(transport.run(), handle_transcriptions(), make_cats())
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.6 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.6 MiB |
Reference in New Issue
Block a user