setup for debian 12
Created: 2025-10-10 20:03:15 | Last updated: 2025-10-10 20:03:15 | Status: Public
SSH into your Pi 5 or work directly on it
Assuming fresh Debian 12 install
============================================
STEP 1: System Update & Essential Tools
============================================
sudo apt update
sudo apt upgrade -y
Install build essentials and development tools
sudo apt install -y \
build-essential \
git \
wget \
curl \
vim \
python3 \
python3-pip \
python3-venv \
python3-dev
Verify Python version (should be 3.11.x)
python3 –version
============================================
STEP 2: Audio System Setup
============================================
Install ALSA and PortAudio (required for pyaudio)
sudo apt install -y \
alsa-base \
alsa-utils \
portaudio19-dev \
libasound2-dev \
libportaudio2 \
libportaudiocpp0
Test audio devices are detected
arecord -l # List recording devices
aplay -l # List playback devices
You should see your USB audio interface listed
If you don’t see your USB device, plug it in and run again
Test microphone recording (Ctrl+C to stop, then play it back)
arecord -D hw:0,0 -f cd test.wav
Press Ctrl+C after 3 seconds
aplay test.wav
If you hear your voice, mic works. If not, try different hw:X,Y values
============================================
STEP 3: Create Project Directory & Virtual Environment
============================================
Create project directory
mkdir -p ~/medic-sam
cd ~/medic-sam
Create Python virtual environment
python3 -m venv venv
Activate virtual environment
source venv/bin/activate
Your prompt should now show (venv) prefix
Always activate this before working: source ~/medic-sam/venv/bin/activate
Upgrade pip in the virtual environment
pip install –upgrade pip
============================================
STEP 4: Install Python Dependencies
============================================
Install audio processing libraries
pip install pyaudio
If pyaudio fails, you might need:
sudo apt install python3-pyaudio
Then: pip install pyaudio
Install OpenWakeWord and its dependencies
pip install openwakeword
This will install:
- onnxruntime (inference engine)
- numpy (numerical operations)
- scipy (audio processing)
- resampy (audio resampling)
Install additional dependencies we’ll need later
pip install \
numpy \
scipy
Verify installations
python3 -c “import pyaudio; print(‘PyAudio:’, pyaudio.version)”
python3 -c “import openwakeword; print(‘OpenWakeWord installed’)”
python3 -c “import numpy; print(‘NumPy:’, numpy.version)”
============================================
STEP 5: Download OpenWakeWord Models
============================================
OpenWakeWord models are downloaded automatically on first run,
but we can pre-download them to verify everything works
python3 << EOF
from openwakeword.model import Model
print(“Downloading default wake word models…”)
oww = Model()
print(“Available models:”, list(oww.models.keys()))
print(“Models downloaded successfully!”)
EOF
You should see models like: hey_mycroft, alexa, hey_jarvis, timer
============================================
STEP 6: Audio Permissions & Configuration
============================================
Add your user to the audio group (if not already)
sudo usermod -a -G audio $USER
You’ll need to log out and back in for this to take effect
Or run: newgrp audio
Verify audio group membership
groups
Should show ‘audio’ in the list
============================================
STEP 7: Create Test Script
============================================
Create the wake word test script
cat > wake_word_test.py << ‘SCRIPT_EOF’
!/usr/bin/env python3
”“”
Medic Sam - Wake Word Detection Test
Minimal script to verify OpenWakeWord is working
“”“
import pyaudio
import numpy as np
from openwakeword.model import Model
Audio configuration
CHUNK_SIZE = 1280 # OpenWakeWord expects 16kHz audio in chunks of 1280 samples (80ms)
SAMPLE_RATE = 16000
CHANNELS = 1
FORMAT = pyaudio.paInt16
def main():
print(“Initializing Medic Sam Wake Word Detection…”)
print(“=” * 50)
# Initialize OpenWakeWord model with default wake words
oww_model = Model(
wakeword_models=["hey_mycroft"],
inference_framework='onnx'
)
print(f"Loaded models: {list(oww_model.models.keys())}")
print("Say 'Hey Mycroft' to trigger detection")
print("(We'll replace this with custom 'Medic Sam' model later)")
print("Press Ctrl+C to exit")
print("=" * 50)
# Initialize PyAudio
audio = pyaudio.PyAudio()
# Find and display available input devices
print("\nAvailable audio input devices:")
for i in range(audio.get_device_count()):
info = audio.get_device_info_by_index(i)
if info['maxInputChannels'] > 0:
print(f" [{i}] {info['name']}")
# Open audio stream
stream = audio.open(
format=FORMAT,
channels=CHANNELS,
rate=SAMPLE_RATE,
input=True,
frames_per_buffer=CHUNK_SIZE
)
print("\nListening for wake word...\n")
try:
while True:
# Read audio chunk
audio_data = stream.read(CHUNK_SIZE, exception_on_overflow=False)
# Convert to numpy array (int16)
audio_array = np.frombuffer(audio_data, dtype=np.int16)
# Get prediction from OpenWakeWord
prediction = oww_model.predict(audio_array)
# Check if wake word detected (threshold: 0.5)
for model_name, score in prediction.items():
if score > 0.5:
print(f">>> WAKE WORD DETECTED! (confidence: {score:.2f})")
print(f" Model: {model_name}")
print()
except KeyboardInterrupt:
print("\n\nShutting down...")
finally:
# Clean up
stream.stop_stream()
stream.close()
audio.terminate()
print("Audio stream closed. Goodbye!")
if name == “main”:
main()
SCRIPT_EOF
Make it executable
chmod +x wake_word_test.py
============================================
STEP 8: Test the Setup
============================================
echo “”
echo “============================================”
echo “Setup complete! Now testing…”
echo “============================================”
echo “”
Run the test script
python3 wake_word_test.py