mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-29 12:39:41 +00:00
fix(utils): handle missing/unresponsive TTS on Linux (#4199)
* fix: handle missing/unresponsive TTS on Linux spd-say may be installed but hang indefinitely when speech-dispatcher is not running. Add a 5s timeout and catch TimeoutExpired alongside FileNotFoundError so recording continues without audio. * chore(utils): add log warning for say --------- Co-authored-by: Jiwen Cai <jiwenc@nvidia.com>
This commit is contained in:
@@ -133,10 +133,13 @@ def say(text: str, blocking: bool = False):
|
||||
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)
|
||||
try:
|
||||
if blocking:
|
||||
subprocess.run(cmd, check=True, timeout=5)
|
||||
else:
|
||||
subprocess.Popen(cmd, creationflags=subprocess.CREATE_NO_WINDOW if system == "Windows" else 0)
|
||||
except (FileNotFoundError, subprocess.TimeoutExpired) as e:
|
||||
logging.warning("Text-to-speech command failed: %s | Error: %s", cmd, e)
|
||||
|
||||
|
||||
def log_say(text: str, play_sounds: bool = True, blocking: bool = False):
|
||||
|
||||
Reference in New Issue
Block a user