Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
942c175b90 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -88,3 +88,5 @@ site/
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
|
||||||
|
models/
|
||||||
@@ -33,36 +33,35 @@ RUN apt-get update && apt-get install -y \
|
|||||||
libasound2 \
|
libasound2 \
|
||||||
libasound2-plugins \
|
libasound2-plugins \
|
||||||
pulseaudio \
|
pulseaudio \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
pulseaudio-utils \
|
||||||
|
libpulse0 \
|
||||||
|
libportaudio2 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& mkdir -p /var/run/pulse /var/lib/pulse
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories
|
||||||
RUN mkdir -p /models/wake_word /audio
|
RUN mkdir -p /models/wake_word /audio && \
|
||||||
|
chown -R 1000:1000 /models /audio && \
|
||||||
|
mkdir -p /home/user/.config/pulse && \
|
||||||
|
chown -R 1000:1000 /home/user
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the wake word detection script
|
# Copy the wake word detection script and audio setup script
|
||||||
COPY wake_word_detector.py .
|
COPY wake_word_detector.py .
|
||||||
|
COPY setup-audio.sh /setup-audio.sh
|
||||||
|
RUN chmod +x /setup-audio.sh
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV WHISPER_MODEL_PATH=/models \
|
ENV WHISPER_MODEL_PATH=/models \
|
||||||
WAKEWORD_MODEL_PATH=/models/wake_word \
|
WAKEWORD_MODEL_PATH=/models/wake_word \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
ASR_MODEL=base.en \
|
PULSE_SERVER=unix:/run/user/1000/pulse/native \
|
||||||
ASR_MODEL_PATH=/models
|
HOME=/home/user
|
||||||
|
|
||||||
# Add resource limits to Python
|
# Run as the host user
|
||||||
ENV PYTHONMALLOC=malloc \
|
USER 1000:1000
|
||||||
MALLOC_TRIM_THRESHOLD_=100000 \
|
|
||||||
PYTHONDEVMODE=1
|
|
||||||
|
|
||||||
# Add healthcheck
|
# Start the application
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
CMD ["/setup-audio.sh"]
|
||||||
CMD ps aux | grep '[p]ython' || exit 1
|
|
||||||
|
|
||||||
# Copy audio setup script
|
|
||||||
COPY setup-audio.sh /setup-audio.sh
|
|
||||||
RUN chmod +x /setup-audio.sh
|
|
||||||
|
|
||||||
# Start command
|
|
||||||
CMD ["/bin/bash", "-c", "/setup-audio.sh && python -u wake_word_detector.py"]
|
|
||||||
@@ -1,7 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Wait for PulseAudio to be ready
|
# Wait for PulseAudio socket to be available
|
||||||
sleep 2
|
while [ ! -e /run/user/1000/pulse/native ]; do
|
||||||
|
echo "Waiting for PulseAudio socket..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Test PulseAudio connection
|
||||||
|
pactl info || {
|
||||||
|
echo "Failed to connect to PulseAudio server"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# List audio devices
|
||||||
|
pactl list sources || {
|
||||||
|
echo "Failed to list audio devices"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start the wake word detector
|
||||||
|
python /app/wake_word_detector.py
|
||||||
|
|
||||||
# Mute the monitor to prevent feedback
|
# Mute the monitor to prevent feedback
|
||||||
pactl set-source-mute alsa_output.pci-0000_00_1b.0.analog-stereo.monitor 1
|
pactl set-source-mute alsa_output.pci-0000_00_1b.0.analog-stereo.monitor 1
|
||||||
|
|||||||
Reference in New Issue
Block a user