Files
esh-pfi-infrastructure/stacks/omnivoice/Dockerfile
T
vh 288d085236 feat(omnivoice): streaming /tts + language-safe sanitizer
Add a live-consumer streaming path and text sanitation to the OmniVoice
wrapper, so it can front speech-to-speech chat engines (not just the
asset-engine's batch WAV use).

- POST /tts: chunked 24 kHz mono s16le PCM (or open-ended WAV), driven by
  the adaptive buffer-ratchet scheduler. Emits the first sentence
  immediately, then ratchets chunk size up on OmniVoice's ~40x realtime
  headroom -> sub-second time-to-first-audio. Wire-compatible with
  chatterbox-fast /tts (both 24 kHz mono PCM). Batch /v1/audio/speech is
  unchanged for asset/file callers.

- scheduler.py: VENDORED byte-faithful copy of chatterbox-fast's pure-
  Python (torch-free) scheduler, pinned to commit 7631462 (v0.1.0/v0.1.1).
  Vendor-copy over a shared package (operator call 2026-06-19): the module
  has no GPU deps, so reuse it without dragging chatterbox-fast's torch
  tree into this image. Promote to a shared package only on a 3rd consumer
  or real drift.

- sanitize.py: language-safe TTS sanitizer run on both endpoints. Strips
  markdown, <think> blocks, HTML, and model control tokens; deliberately
  SKIPS the fork's English-only number/phone normalization that would
  corrupt OmniVoice's 600-language input. Preserves [laughter]-style tags.

- Refactor: shared GenParams base for SpeechRequest + TTSStreamRequest;
  single GEN_LOCK serializes generation (single-stream interactive).

- Dockerfile/playbook: copy + upload the two new modules; build-time
  `import app` smoke; correct stale "Gradio demo / no FastAPI" comments.
2026-06-19 22:47:15 -07:00

63 lines
2.6 KiB
Docker

# syntax=docker/dockerfile:1.6
#
# OmniVoice (k2-fsa/OmniVoice) — zero-shot, massively-multilingual (600+
# languages) voice-cloning + voice-design TTS, diffusion-LM architecture,
# Apache-2.0. Upstream ships a pip package + its own Gradio demo
# (`omnivoice-demo`); there's no official image, so we build a thin CUDA
# container around the pip package and run our OWN FastAPI wrapper (app.py):
# a batch OpenAI-style /v1/audio/speech plus a streaming /tts driven by the
# vendored buffer-ratchet scheduler (scheduler.py) for live chat consumers.
ARG CUDA_BASE=nvidia/cuda:12.8.0-cudnn-runtime-ubuntu22.04
FROM ${CUDA_BASE}
ENV DEBIAN_FRONTEND=noninteractive \
PIP_ROOT_USER_ACTION=ignore \
PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:${PATH}"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3.10 python3.10-venv python3-pip \
git ffmpeg libsndfile1 \
ca-certificates wget \
&& rm -rf /var/lib/apt/lists/* \
&& python3.10 -m venv /opt/venv
# CUDA 12.8 torch wheels (per OmniVoice's documented install line).
RUN pip install --no-cache-dir \
torch==2.8.0 torchaudio==2.8.0 \
--index-url https://download.pytorch.org/whl/cu128
# OmniVoice from PyPI (+ huggingface_hub for the entrypoint weight pre-warm).
# Optional reproducible pin via the OMNIVOICE_VERSION build arg (empty=latest).
ARG OMNIVOICE_VERSION=
RUN pip install --no-cache-dir "omnivoice${OMNIVOICE_VERSION:+==${OMNIVOICE_VERSION}}" huggingface_hub
# Our asset-engine wrapper deps (FastAPI stack + soundfile for WAV encoding).
RUN pip install --no-cache-dir fastapi 'uvicorn[standard]' soundfile python-multipart
# Fail the build loudly if the runtime imports aren't satisfiable.
RUN python -c "import omnivoice, fastapi, soundfile, uvicorn; print('omnivoice wrapper deps OK')"
WORKDIR /app
COPY app.py /app/app.py
COPY scheduler.py /app/scheduler.py
COPY sanitize.py /app/sanitize.py
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Fail the build if the wrapper (incl. the vendored scheduler + sanitizer) won't
# import. Model load is lazy (startup event), so this is a cheap CPU-only check.
RUN python -c "import app; print('omnivoice app import OK')"
EXPOSE 8001
# Our wrapper exposes /healthz (200 once model + >=1 voice are loaded). Generous
# start period: first boot pre-warms OmniVoice + Whisper ASR + clones every voice.
HEALTHCHECK --interval=30s --timeout=10s --start-period=1200s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:8001/healthz || exit 1
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8001"]