add convert aloha 2 lerobot
This commit is contained in:
@@ -270,3 +270,53 @@ def init_keyboard_listener():
|
||||
listener.start()
|
||||
|
||||
return listener, events
|
||||
|
||||
|
||||
import yaml
|
||||
from argparse import Namespace
|
||||
def load_config(yaml_path):
|
||||
"""Load configuration from YAML file and return as Namespace object"""
|
||||
with open(yaml_path, 'r') as f:
|
||||
config_dict = yaml.safe_load(f)
|
||||
|
||||
# Convert dict to Namespace (similar to argparse.Namespace)
|
||||
return Namespace(**config_dict)
|
||||
|
||||
|
||||
import platform
|
||||
import subprocess
|
||||
# import pyttsx3
|
||||
def say(text, blocking=False):
|
||||
system = platform.system()
|
||||
|
||||
if system == "Darwin":
|
||||
cmd = ["say", text]
|
||||
|
||||
elif system == "Linux":
|
||||
# cmd = ["spd-say", text]
|
||||
# if blocking:
|
||||
# cmd.append("--wait")
|
||||
cmd = ["edge-playback", "--text", text]
|
||||
|
||||
elif system == "Windows":
|
||||
cmd = [
|
||||
"PowerShell",
|
||||
"-Command",
|
||||
"Add-Type -AssemblyName System.Speech; "
|
||||
f"(New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('{text}')",
|
||||
]
|
||||
|
||||
else:
|
||||
raise RuntimeError("Unsupported operating system for text-to-speech.")
|
||||
|
||||
if blocking:
|
||||
subprocess.run(cmd, check=True)
|
||||
else:
|
||||
subprocess.Popen(cmd, creationflags=subprocess.CREATE_NO_WINDOW if system == "Windows" else 0)
|
||||
|
||||
|
||||
def log_say(text, play_sounds, blocking=False):
|
||||
print(text)
|
||||
|
||||
if play_sounds:
|
||||
say(text, blocking)
|
||||
|
||||
Reference in New Issue
Block a user