#!/bin/sh set -eu target=/opt/hermes/cron/scheduler_delivery.py broken='env.pop("HERMES_HOME", None)' if [ -f "$target" ] && grep -Fq "$broken" "$target"; then sed -i '/^[[:space:]]*env\.pop("HERMES_HOME", None)[[:space:]]*$/d' "$target" echo "[cron-profile-root-fix] preserved HERMES_HOME for named-profile delivery" else echo "[cron-profile-root-fix] upstream code already fixed or layout changed; no action" fi cli_dir="${HERMES_HOME:-/opt/data}/.local/bin" mkdir -p "$cli_dir" ln -sfn /opt/hermes/.venv/bin/hermes "$cli_dir/hermes" ln -sfn /opt/hermes/.venv/bin/hermes /usr/local/bin/hermes # Hermes streams each detected sentence to TTS separately. Its generic # sentence splitter treats periods in German abbreviations as sentence ends, # causing the following words to become unrelated utterances. Expand these # abbreviations before splitting. tts_target=/opt/hermes/tools/tts_streaming.py tts_old=' self.buf = _THINK_BLOCK_RE.sub("", self.buf + delta)' tts_new=' self.buf = _THINK_BLOCK_RE.sub("", self.buf + delta) self.buf = re.sub(r"\bca\.(?=\s)", "circa", self.buf, flags=re.IGNORECASE) self.buf = re.sub(r"\bv\.\s*a\.(?=\s)", "vor allem", self.buf, flags=re.IGNORECASE) self.buf = re.sub(r"\bmax\.(?=\s)", "maximal", self.buf, flags=re.IGNORECASE)' if [ -f "$tts_target" ] && grep -Fq "$tts_old" "$tts_target"; then TTS_TARGET="$tts_target" TTS_OLD="$tts_old" TTS_NEW="$tts_new" python3 -c \ 'import os; from functools import reduce; from pathlib import Path; p = Path(os.environ["TTS_TARGET"]); s = p.read_text(); lines = [" self.buf = re.sub(r\"\\bca\\.(?=\\s)\", \"circa\", self.buf, flags=re.IGNORECASE)", " self.buf = re.sub(r\"\\bv\\.\\s*a\\.(?=\\s)\", \"vor allem\", self.buf, flags=re.IGNORECASE)", " self.buf = re.sub(r\"\\bmax\\.(?=\\s)\", \"maximal\", self.buf, flags=re.IGNORECASE)"]; s = reduce(lambda value, line: value.replace("\n" + line, ""), lines, s); p.write_text(s.replace(os.environ["TTS_OLD"], os.environ["TTS_NEW"], 1))' echo "[tts-streaming-fix] expanded German abbreviations before sentence splitting" else echo "[tts-streaming-fix] upstream code already fixed or layout changed; no action" fi