uezo / aiavatarkit

🥰 Building AI-based conversational avatars lightning fast ⚡️💬
Apache License 2.0
261 stars 22 forks source link

Add VideoDevice to control camera for vision input📷 #59

Closed uezo closed 5 months ago

uezo commented 5 months ago

Usage

import io
import pyautogui
from aiavatar.device.video import VideoDevice

default_camera = VideoDevice()

# get_image that supports multiple source
async def get_image(source) -> bytes:
    if source == "camera":
        return await default_camera.capture_image()
    else:
        buffered = io.BytesIO()
        image = pyautogui.screenshot(region=(0, 0, 1280, 720))
        image.save(buffered, format="PNG")
        return buffered.getvalue()

# ChatGPT Processor with Vision
chat_processor_gpt = ChatGPTProcessor(
    api_key=OPENAI_API_KEY,
    model="gpt-4o",
    system_message_content=PROMPT,
    use_vision=True
)

# Set `get_image`
chat_processor_gpt.get_image = get_image