From cd0fc261c051f4fabf352844f6bed6c3db74d688 Mon Sep 17 00:00:00 2001 From: Alexander Soare Date: Thu, 17 Oct 2024 15:22:21 +0100 Subject: [PATCH] Make `say(blocking=True)` work for Linux (#460) --- lerobot/common/utils/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lerobot/common/utils/utils.py b/lerobot/common/utils/utils.py index 554e054e8..4e276e169 100644 --- a/lerobot/common/utils/utils.py +++ b/lerobot/common/utils/utils.py @@ -196,19 +196,19 @@ def say(text, blocking=False): # Check if mac, linux, or windows. if platform.system() == "Darwin": cmd = f'say "{text}"' + if not blocking: + cmd += " &" elif platform.system() == "Linux": cmd = f'spd-say "{text}"' + if blocking: + cmd += " --wait" elif platform.system() == "Windows": + # TODO(rcadene): Make blocking option work for Windows cmd = ( 'PowerShell -Command "Add-Type -AssemblyName System.Speech; ' f"(New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('{text}')\"" ) - if not blocking and platform.system() in ["Darwin", "Linux"]: - # TODO(rcadene): Make it work for Windows - # Use the ampersand to run command in the background - cmd += " &" - os.system(cmd)