BREAKING FIX: Browser Whisper now fully self-contained Previous issue: - Loaded transformers.js from cdn.jsdelivr.net - Downloaded models from cdn-lfs.huggingface.co - Failed in corporate/clinical networks with firewall - Stuck at "Initializing..." with no progress Solution: - Bundle transformers.js library (~876KB) - Bundle Whisper tiny.en model (~42MB) - Serve everything from local server - Works in ANY network environment Changes: - whisperWorker.js: Load transformers from /models/ instead of CDN - Dockerfile: Download models during Docker build - Add download script for local dev - Add comprehensive setup documentation Docker image size: +~42MB (one-time cost, runtime benefit) Tested: Works on unrestricted and firewalled networks
36 lines
1.7 KiB
Docker
36 lines
1.7 KiB
Docker
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# ffmpeg: audio conversion for AWS Transcribe (WebM → PCM)
|
|
# curl: download Whisper models for browser-based transcription
|
|
RUN apk add --no-cache ffmpeg curl
|
|
|
|
COPY package.json ./
|
|
RUN npm install --omit=dev
|
|
|
|
COPY . .
|
|
|
|
RUN mkdir -p /app/data/logs
|
|
|
|
# Download Browser Whisper models (self-hosted, no CDN dependency)
|
|
RUN mkdir -p /app/public/models/Xenova/whisper-tiny.en/onnx && \
|
|
cd /app/public/models/Xenova/whisper-tiny.en && \
|
|
echo "Downloading Whisper model files..." && \
|
|
curl -sL -o config.json https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/config.json && \
|
|
curl -sL -o tokenizer.json https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/tokenizer.json && \
|
|
curl -sL -o preprocessor_config.json https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/preprocessor_config.json && \
|
|
curl -sL -o generation_config.json https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/generation_config.json && \
|
|
curl -sL -o onnx/encoder_model_quantized.onnx https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/onnx/encoder_model_quantized.onnx && \
|
|
curl -sL -o onnx/decoder_model_merged_quantized.onnx https://huggingface.co/Xenova/whisper-tiny.en/resolve/main/onnx/decoder_model_merged_quantized.onnx && \
|
|
cd /app/public/models && \
|
|
curl -sL -o transformers.min.js https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2/dist/transformers.min.js && \
|
|
echo "Whisper models downloaded successfully"
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
|
|
|
|
CMD ["node", "server.js"]
|
|
|