Files
esh-pfi-infrastructure/stacks/parakeet/Dockerfile
T
vh 01c5380059 parakeet: rewrite on sherpa-onnx; own the wrapper end-to-end
The Shadowfita FastAPI wrapper hit two unfixed upstream bugs on the
first real /transcribe call — chunker return-shape mismatch (open
issue #16) and a `torchaudio.tensor` that doesn't exist (open #10).
Rather than babysit someone else's half-tested code, switched to
sherpa-onnx with the prebuilt int8 Parakeet-TDT tarball from k2-fsa,
and wrote our own ~60-line FastAPI wrapper.

Moving parts now owned in-tree:
  Dockerfile      CUDA 12.8 + cuDNN 9 runtime base, installs
                  sherpa-onnx==1.12.39+cuda12.cudnn9 + fastapi +
                  soundfile + libasound2 (sherpa-onnx links to ALSA
                  at load time even when we never touch a mic).
  app.py          OfflineRecognizer.from_transducer() once at startup;
                  /transcribe and /v1/audio/transcriptions both accept
                  multipart uploads and return {"text": ...}.
  entrypoint.sh   Idempotent model download to /models on first run
                  (~400 MB int8 tarball), then exec uvicorn.

Smoke test: 0.wav (bundled in the tarball, The House of the Seven
Gables excerpt) transcribes cleanly in ~1.2s on GPU.

PARAKEET_MODEL_URL in .env lets you swap to the v3 (25-language)
tarball without touching any other files. Wipe *.onnx + tokens.txt
from the models dir and the entrypoint re-downloads.
2026-04-24 00:18:45 -07:00

42 lines
1.1 KiB
Docker

# syntax=docker/dockerfile:1.6
#
# Parakeet-TDT ASR via sherpa-onnx (ONNX Runtime + CUDA).
#
# We own this whole image — not forked from an upstream wrapper. ~70 MB of
# application layer over the CUDA+cuDNN runtime base.
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 python3-pip python3-venv \
libsndfile1 \
libasound2 \
ca-certificates wget bzip2 \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m venv /opt/venv
RUN pip install --no-cache-dir \
fastapi \
'uvicorn[standard]' \
python-multipart \
soundfile \
numpy \
&& pip install --no-cache-dir \
sherpa-onnx==1.12.39+cuda12.cudnn9 \
-f https://k2-fsa.github.io/sherpa/onnx/cuda.html
WORKDIR /app
COPY app.py /app/app.py
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]