#!/usr/bin/env bash
# Launch the browser (WebRTC) version of Sofia for fast iteration — same brain as the
# phone agent, served at http://localhost:7860. Mirrors run.sh (venv + CUDA libs + .env).
set -euo pipefail

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV="/home/tocmo0nlord/pipecat-run/.venv"

# faster-whisper (ctranslate2) needs the CUDA12 cublas + cudnn shared libs at runtime.
NV="$VENV/lib/python3.13/site-packages/nvidia"
export LD_LIBRARY_PATH="$NV/cublas/lib:$NV/cudnn/lib:${LD_LIBRARY_PATH:-}"

# Load .env (model, voice, VAD, etc.) — same config the phone agent uses.
if [ -f "$HERE/.env" ]; then
  set -a; . "$HERE/.env"; set +a
fi

cd "$HERE"
echo "Sofia (browser) starting — open http://localhost:7860 once it's up."
exec "$VENV/bin/python" bot_web.py
