Spaces:
Sleeping
Sleeping
File size: 1,551 Bytes
2b84626 07b85e8 2b84626 07b85e8 2b84626 07b85e8 2b84626 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/usr/bin/env bash
set -euo pipefail
PORT="${PORT:-7860}"
MODEL_PATH="${WHISPER_MODEL_PATH:-}"
WHISPER_LANGUAGE="${WHISPER_LANGUAGE:-uz}"
WHISPER_BACKEND="${WHISPER_BACKEND:-whisper}"
WHISPER_BACKEND_POLICY="${WHISPER_BACKEND_POLICY:-localagreement}"
WHISPERLIVEKIT_ARGS="${WHISPERLIVEKIT_ARGS:-}"
if [ -z "${MODEL_PATH}" ]; then
MODEL_PATH="$(python /app/download_models.py)"
fi
if command -v wlk >/dev/null 2>&1; then
WLK_CMD="wlk"
elif command -v whisperlivekit-server >/dev/null 2>&1; then
WLK_CMD="whisperlivekit-server"
else
echo "Neither 'wlk' nor 'whisperlivekit-server' is available on PATH." >&2
exit 1
fi
HELP_FILE="/tmp/whisperlivekit-help.txt"
"${WLK_CMD}" --help >"${HELP_FILE}" 2>&1 || true
ARGS=(--host 0.0.0.0 --port "${PORT}")
if grep -q -- "--model-path" "${HELP_FILE}"; then
ARGS+=(--model-path "${MODEL_PATH}")
else
ARGS+=(--model "${MODEL_PATH}")
fi
if [ -n "${WHISPER_LANGUAGE}" ] && grep -q -- "--language" "${HELP_FILE}"; then
ARGS+=(--language "${WHISPER_LANGUAGE}")
fi
if [ -n "${WHISPER_BACKEND}" ] && grep -q -- "--backend" "${HELP_FILE}"; then
ARGS+=(--backend "${WHISPER_BACKEND}")
fi
if [ -n "${WHISPER_BACKEND_POLICY}" ] && grep -q -- "--backend-policy" "${HELP_FILE}"; then
ARGS+=(--backend-policy "${WHISPER_BACKEND_POLICY}")
fi
if [ -n "${WHISPERLIVEKIT_ARGS}" ]; then
read -r -a EXTRA_ARGS <<<"${WHISPERLIVEKIT_ARGS}"
ARGS+=("${EXTRA_ARGS[@]}")
fi
echo "Starting WhisperLiveKit on 0.0.0.0:${PORT} with model ${MODEL_PATH}"
exec "${WLK_CMD}" "${ARGS[@]}"
|