#!/bin/bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" VENV_DIR="$ROOT_DIR/.venv" REQ_FILE="$ROOT_DIR/s2s-client/requirements.txt" UI_PORT="${UI_PORT:-8420}" if [ -f "$ROOT_DIR/.env" ]; then set -a source "$ROOT_DIR/.env" set +a fi S2S_PROXY_TARGET="${S2S_PROXY_TARGET:-ws://ai-server:12345/v1/realtime}" if ! command -v python3 >/dev/null 2>&1; then echo "Error: python3 was not found." exit 1 fi if [ ! -d "$VENV_DIR" ]; then echo "Creating the virtual environment in .venv..." python3 -m venv "$VENV_DIR" fi source "$VENV_DIR/bin/activate" if [ ! -f "$REQ_FILE" ]; then echo "Error: requirements file was not found: $REQ_FILE" exit 1 fi if ! python -c "import fastapi, uvicorn, httpx, huggingface_hub, dotenv" >/dev/null 2>&1; then echo "Installing dependencies from s2s-client/requirements.txt..." python -m pip install -r "$REQ_FILE" fi export S2S_PROXY_TARGET echo "💻 Starting the S2S client UI (port $UI_PORT)..." echo "🔌 Realtime proxy target: $S2S_PROXY_TARGET" echo " Press Ctrl+C in this terminal to stop it." echo "----------------------------------------------------" cd "$ROOT_DIR" PYTHONPATH=s2s-client python -m uvicorn server:app --host 0.0.0.0 --port "$UI_PORT" --reload