# OmniVoice (k2-fsa/OmniVoice) — zero-shot, massively-multilingual (600+
# language) voice-cloning + voice-design TTS, diffusion-LM, Apache-2.0.
# Served behind our OWN thin FastAPI wrapper (stacks/omnivoice/app.py) exposing
# OpenAI-compatible /v1/audio/speech (+ /v1/audio/voices, /healthz) so the
# asset-engine can consume it. Upstream ships only a Gradio demo; the wrapper
# replaced it (2026-06-19). Voices are reference WAVs in ${OMNIVOICE_VOICES_DIR}
# (the reused chatterbox /refs/*.wav); clone prompts are precomputed at startup.
#
# Build: local image from the Dockerfile in this dir. Weights download
# from HF (k2-fsa/OmniVoice) on first boot into ${OMNIVOICE_CACHE_DIR}.
#
# Pinned to the 3090 (device 0) on irv-ml1 — the A6000 (device 1) is
# ComfyUI-exclusive after the 2026-06-18 VRAM consolidation. OmniVoice
# runs in well under 5 GB; the 3090 had ~18 GB free.
#
# All tunables live in .env — edit that, not this file.

# Compose project name MUST equal the catalog lifecycle.stack ("omnivoice") or the
# asset-engine liveness probe (docker ps project-name match) shows it OFFLINE.
name: omnivoice

services:
  omnivoice:
    image: local/omnivoice:${OMNIVOICE_TAG:-latest}
    build:
      context: .
      dockerfile: Dockerfile
      args:
        OMNIVOICE_VERSION: ${OMNIVOICE_VERSION:-}
    container_name: omnivoice
    restart: unless-stopped
    runtime: nvidia
    ports:
      - "${OMNIVOICE_BIND:-0.0.0.0}:${OMNIVOICE_PORT}:8001"
    environment:
      - NVIDIA_VISIBLE_DEVICES=${OMNIVOICE_GPU_DEVICES:-0}
      - HF_HOME=/app/hf_cache
      # Streaming /tts scheduler prior — high = pack aggressively (diffusion has a
      # ~fixed per-call overhead; low priors over-chunk and starve). See app.py.
      - OMNIVOICE_STREAM_RTF_PRIOR=${OMNIVOICE_STREAM_RTF_PRIOR:-20}
    volumes:
      - ${OMNIVOICE_CACHE_DIR}:/app/hf_cache
      - ${OMNIVOICE_VOICES_DIR}:/app/voices
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:8001/healthz || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      # First boot: OmniVoice + Whisper ASR pre-warm + cloning every staged voice.
      start_period: 1200s
    labels:
      - homepage.group=AI - Dormant
      - homepage.name=OmniVoice
      - homepage.icon=mdi-account-voice
      - homepage.description=Zero-shot multilingual voice-cloning TTS, OpenAI /v1/audio/speech (irv-ml1, 3090)
      - homepage.href=http://10.100.79.3:${OMNIVOICE_PORT}/docs
