#!/bin/bash
# Run VibeVoice Realtime ASR Server
#
# Usage:
#   ./run_realtime.sh [options]
#
# Options are passed to the server (see --help for details)

set -e

cd "$(dirname "$0")"

# Default options
HOST="${VIBEVOICE_HOST:-0.0.0.0}"
PORT="${VIBEVOICE_PORT:-8000}"
MODEL_PATH="${VIBEVOICE_MODEL_PATH:-microsoft/VibeVoice-ASR}"
DEVICE="${VIBEVOICE_DEVICE:-cuda}"
MAX_SESSIONS="${VIBEVOICE_MAX_SESSIONS:-10}"

echo "=========================================="
echo "VibeVoice Realtime ASR Server"
echo "=========================================="
echo "Host: $HOST"
echo "Port: $PORT"
echo "Model: $MODEL_PATH"
echo "Device: $DEVICE"
echo "Max Sessions: $MAX_SESSIONS"
echo "=========================================="
echo ""
echo "Web client: http://$HOST:$PORT/static/realtime_client.html"
echo "WebSocket: ws://$HOST:$PORT/ws/asr/{session_id}"
echo ""

# Run server
python -m realtime.server \
    --host "$HOST" \
    --port "$PORT" \
    --model-path "$MODEL_PATH" \
    --device "$DEVICE" \
    --max-sessions "$MAX_SESSIONS" \
    "$@"
