From 6b7d6da47ce8f46b9a2a35b9354ebefd0c205017 Mon Sep 17 00:00:00 2001 From: kassam Date: Thu, 23 Apr 2026 09:55:45 +0400 Subject: [PATCH] Update 2026-04-23 09:55:45 --- scripts/start_saqr.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/scripts/start_saqr.sh b/scripts/start_saqr.sh index 37bf460..21126dc 100755 --- a/scripts/start_saqr.sh +++ b/scripts/start_saqr.sh @@ -70,6 +70,36 @@ cd "$SAQR_DIR" || { } echo "[start_saqr] env=$CONDA_ENV cwd=$PWD iface=$DDS_IFACE source=$SAQR_SOURCE stream=$STREAM_PORT" + +# ── Clear competing voice/audio processes ─────────────────────────────────── +# The G1 firmware voice service (TtsMaker / PlayStream) goes into a +# "busy" state — returning rc=3104 or silently dropping audio — when +# another process on the robot holds the audio channel. Known offenders +# on this robot: sanad_voice.service, sanad_webserver, marcus_voice, +# and stale saqr bridge/saqr_cli instances left by previous runs. +# Kill them all before starting so the firmware starts from a clean +# state. All commands are best-effort (|| true) and non-interactive +# (sudo -n) so they never block. +echo "[start_saqr] clearing competing voice/audio processes..." +killed=0 +for svc in sanad_voice.service sanad_webserver.service marcus_voice.service; do + if sudo -n systemctl stop "$svc" >/dev/null 2>&1; then + echo "[start_saqr] stopped systemd unit: $svc" + killed=1 + fi +done +for pattern in sanad_voice sanad_webserver marcus_voice gemini_voice \ + 'python.*robot\.bridge' 'python.*apps\.saqr_cli'; do + if pkill -f "$pattern" >/dev/null 2>&1; then + echo "[start_saqr] killed: $pattern" + killed=1 + fi +done +if [ "$killed" -eq 1 ]; then + # Give the firmware a beat to release the voice RPC service. + sleep 1 +fi + echo "[start_saqr] launching bridge..." exec python3 -m robot.bridge \