update fal image_gen to use size in constructor

This commit is contained in:
Moishe Lettvin
2024-01-18 11:29:13 -05:00
parent f9f2e2d7ea
commit 0245f98eb5
2 changed files with 7 additions and 9 deletions

View File

@@ -9,12 +9,10 @@ from PIL import Image
from dailyai.services.ai_services import LLMService, TTSService, ImageGenService from dailyai.services.ai_services import LLMService, TTSService, ImageGenService
# Fal expects FAL_KEY_ID and FAL_KEY_SECRET to be set in the env # Fal expects FAL_KEY_ID and FAL_KEY_SECRET to be set in the env
class FalImageGenService(ImageGenService): class FalImageGenService(ImageGenService):
def __init__(self): def __init__(self, image_size):
super().__init__() super().__init__(image_size)
async def run_image_gen(self, sentence) -> tuple[str, bytes]:
async def run_image_gen(self, sentence, size) -> tuple[str, bytes]:
def get_image_url(sentence, size): def get_image_url(sentence, size):
print("starting fal submit...") print("starting fal submit...")
handler = fal.apps.submit( handler = fal.apps.submit(
@@ -37,7 +35,7 @@ class FalImageGenService(ImageGenService):
return image_url return image_url
print(f"fetching image url...") print(f"fetching image url...")
image_url = await asyncio.to_thread(get_image_url, sentence, size) image_url = await asyncio.to_thread(get_image_url, sentence, self.image_size)
print(f"got image url, downloading image...") print(f"got image url, downloading image...")
# Load the image from the url # Load the image from the url
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:

View File

@@ -27,9 +27,9 @@ async def main(room_url):
transport.camera_height = 1024 transport.camera_height = 1024
llm = AzureLLMService() llm = AzureLLMService()
dalle = FalImageGenService() dalle = FalImageGenService(image_size="1024x1024")
tts = ElevenLabsTTSService(voice_id="ErXwobaYiN019PkySvjV") tts = ElevenLabsTTSService(voice_id="ErXwobaYiN019PkySvjV")
#dalle = OpenAIImageGenService(image_size="1024x1024") # dalle = OpenAIImageGenService(image_size="1024x1024")
# Get a complete audio chunk from the given text. Splitting this into its own # Get a complete audio chunk from the given text. Splitting this into its own
# coroutine lets us ensure proper ordering of the audio chunks on the send queue. # coroutine lets us ensure proper ordering of the audio chunks on the send queue.