|
from dora import DoraStatus |
|
import numpy as np |
|
import pyarrow as pa |
|
from idefics2_utils import ask_vlm |
|
import pyttsx3 |
|
|
|
|
|
KITCHEN = np.array([[0.5, 0], [0.5, -0.5], [1.0, -1.0]]).ravel() |
|
HOME = np.array([[0.5, -0.5], [0, 0]]).ravel() |
|
|
|
|
|
|
|
class Operator: |
|
def __init__(self): |
|
engine = pyttsx3.init("espeak") |
|
voices = engine.getProperty("voices") |
|
engine.setProperty("voice", voices[3].id) |
|
self.engine = engine |
|
|
|
def speak(self, text: str): |
|
self.engine.say(text) |
|
|
|
|
|
def ask_model(self, image: np.ndarray, text: str) -> str: |
|
text = ask_vlm(image, text) |
|
return "Yes, " in text |
|
|
|
def on_event( |
|
self, |
|
dora_event: dict, |
|
send_output, |
|
) -> DoraStatus: |
|
if dora_event["type"] == "INPUT": |
|
id = dora_event["id"] |
|
|
|
if id == "init": |
|
send_output("set_goal", pa.array([])) |
|
|
|
|
|
elif id == "goal_reached": |
|
image = dora_event["value"].to_numpy().reshape((540, 960, 3)) |
|
pass |
|
|
|
return DoraStatus.CONTINUE |
|
|