# Parakeet ASR via sherpa-onnx + our own thin FastAPI wrapper.
#
# We previously wrapped Shadowfita/parakeet-tdt-0.6b-v2-fastapi but hit two
# unfixed upstream bugs (open issues #16 + #10) the first time we actually sent
# a transcription request. Switched to sherpa-onnx — ONNX Runtime + CUDA, a
# prebuilt int8 quantized Parakeet-TDT from k2-fsa — and wrote our own ~50-line
# wrapper we own end-to-end.
#
# Model weights (~400 MB int8) download on first run via the entrypoint to
# ${PARAKEET_MODELS_DIR}/ (persistent host bind mount). Subsequent starts skip
# the download.
#
# API:
#   POST /transcribe                  — multipart file upload, returns {"text": "..."}
#   POST /v1/audio/transcriptions     — same body, OpenAI-compatible path alias
#   GET  /healthz
#
# All tunables live in .env — edit that, not this file.

services:
  parakeet:
    image: local/parakeet:${PARAKEET_TAG}
    build:
      context: .
      dockerfile: Dockerfile
    container_name: parakeet
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "${PARAKEET_BIND:-0.0.0.0}:${PARAKEET_PORT}:8000"
    environment:
      - NVIDIA_VISIBLE_DEVICES=0
      - MODEL_DIR=/models
      - MODEL_URL=${PARAKEET_MODEL_URL}
      - PROVIDER=${PARAKEET_PROVIDER:-cuda}
      - NUM_THREADS=${PARAKEET_NUM_THREADS:-1}
      - LOG_LEVEL=${PARAKEET_LOG_LEVEL:-INFO}
    volumes:
      - ${PARAKEET_MODELS_DIR}:/models
    healthcheck:
      # Image ships wget (apt) but not curl — use wget so the check actually runs.
      test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:8000/healthz || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      # First boot may include a ~400 MB model download.
      start_period: 300s
    labels:
      - homepage.group=AI - Audio Tools
      - homepage.name=Parakeet ASR
      - homepage.icon=mdi-microphone
      - homepage.description=Parakeet-TDT speech-to-text via sherpa-onnx (irv-ml1)
      - homepage.href=http://10.100.79.3:${PARAKEET_PORT}
