fix: Silero VAD model download

This commit is contained in:
Sabiha Khan 2025-11-13 09:52:38 +05:30
parent dc6d696af6
commit ed1140b21a
2 changed files with 51 additions and 2 deletions

View file

@ -20,9 +20,12 @@ RUN pip install --user --no-cache-dir -r requirements.txt && \
# Copy and install pipecat from local submodule
COPY pipecat /tmp/pipecat
COPY scripts/download_model.sh /tmp/download_model.sh
RUN pip install --user --no-cache-dir '/tmp/pipecat[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc]' && \
# Clean up pip cache and temporary pipecat directory
rm -rf /root/.cache/pip /tmp/pipecat
# Copy Silero VAD model using dedicated script (before cleaning up pipecat source)
bash /tmp/download_model.sh && \
# Clean up pip cache and temporary files
rm -rf /root/.cache/pip /tmp/pipecat /tmp/download_model.sh
# Remove unnecessary Python cache files from installed packages

46
scripts/download_model.sh Executable file
View file

@ -0,0 +1,46 @@
#!/bin/bash
# Script to copy Silero VAD model during Docker build.
# This ensures the model is available at runtime.
set -e
# Source model path from the pipecat installation
SOURCE_MODEL_PATH="/tmp/pipecat/src/pipecat/audio/vad/data/silero_vad.onnx"
# Target model path in the installed package
USER_SITE=$(python -c "import site; print(site.getusersitepackages())")
VAD_DATA_DIR="$USER_SITE/pipecat/audio/vad/data"
TARGET_MODEL_PATH="$VAD_DATA_DIR/silero_vad.onnx"
echo "Setting up Silero VAD model..."
# Create the VAD data directory if it doesn't exist
mkdir -p "$VAD_DATA_DIR"
# Check if model already exists
if [ -f "$TARGET_MODEL_PATH" ]; then
echo "✓ Silero VAD model already exists at: $TARGET_MODEL_PATH"
exit 0
fi
# Check if source model exists
if [ ! -f "$SOURCE_MODEL_PATH" ]; then
echo "✗ Source model not found at: $SOURCE_MODEL_PATH"
exit 1
fi
echo "Copying Silero VAD model from pipecat source..."
# Copy the model file
cp "$SOURCE_MODEL_PATH" "$TARGET_MODEL_PATH"
# Verify the model file exists and get its size
if [ -f "$TARGET_MODEL_PATH" ]; then
FILE_SIZE=$(stat -c%s "$TARGET_MODEL_PATH" 2>/dev/null || stat -f%z "$TARGET_MODEL_PATH" 2>/dev/null)
echo "✓ Silero VAD model successfully copied to: $TARGET_MODEL_PATH ($FILE_SIZE bytes)"
else
echo "✗ Failed to copy model file to: $TARGET_MODEL_PATH"
exit 1
fi
echo "Silero VAD model setup complete!"