A comprehensive wrapper for deploying and managing the Raspberry Pi voice-assistant client. This wrapper handles all dependencies, services, and automatic updates.
The installation process is now much simpler! With the new device authentication system:
- Only 2 environment variables needed:
DEVICE_IDandDEVICE_PRIVATE_KEY - No API keys required on device: All keys fetched from backend automatically
- Provision via admin portal: Download pre-configured installer package
- Centralized management: Update API keys without touching devices
- Admin Portal: Provision device → generates keys → download installer zip
- Device: Unzip → run
./install.sh→ everything auto-configured - Runtime: Device authenticates → fetches all API keys and settings from backend
This wrapper automates the setup and management of the voice-assistant client on Raspberry Pi with ReSpeaker. It handles:
- System dependency installation
- OpenTelemetry collector setup with persistent logging
- Automatic code updates from git
- Systemd service management for auto-start on boot
- Python virtual environment and dependency management
- Device authentication with automatic key fetching
raspberry-pi-client-wrapper/
├── install.sh # One-time installation script
├── launch.sh # Runtime launcher (run by systemd)
├── uninstall.sh # Uninstallation script
├── reinstall.sh # Reinstall script
├── monitor/
│ └── device_monitor.sh # Remote intervention monitor
├── respeaker/
│ ├── respeaker-init.sh # ReSpeaker tuning initialization
│ └── RESPEAKER_TUNING.md # ReSpeaker configuration guide
├── otel/
│ ├── install-collector.sh # OpenTelemetry collector installer
│ ├── otel-collector-config.yaml
│ └── .cache/ # Downloaded tarballs (gitignored)
├── services/
│ └── xavier.service # Systemd service template
├── xavier/ # Git cloned here (gitignored)
└── README.md # This file
- Raspberry Pi 5 (recommended) or Pi 4
- ReSpeaker 4-Mic Array (with hardware AEC)
- MicroSD card (32GB+ recommended)
- Stable internet connection
- Raspberry Pi OS Lite (64-bit) or Desktop
- Fresh system or clean install recommended
This is the easiest method! The installer package is generated by the admin portal with all credentials pre-configured.
-
Provision device in admin portal:
- Go to Device Management → Unregistered Devices
- Click "Provision New Device"
- Enter device name and serial number
- Download installer package (zip file)
-
Copy to Raspberry Pi:
# On your computer scp raspberry-pi-client-wrapper-<device-id>.zip [email protected]:~/ # On the Pi ssh [email protected] cd ~ unzip raspberry-pi-client-wrapper-<device-id>.zip cd raspberry-pi-client-wrapper
-
Run installation - completely automated:
./install.sh # Everything pre-configured! No prompts needed. -
Done!
- Device automatically authenticates
- All API keys fetched from backend
- Services start automatically
The .env file is already included with:
DEVICE_ID=<auto-generated-uuid>
DEVICE_PRIVATE_KEY=<generated-key>
OTEL_CENTRAL_COLLECTOR_ENDPOINT=<your-endpoint>
ENV=production
# Optional (defaults apply if not set):
# GIT_BRANCH=main (default: main)For manual setup without the admin portal:
-
Create
.envfile with:DEVICE_ID=your-device-id DEVICE_PRIVATE_KEY=your-private-key ENV=production OTEL_CENTRAL_COLLECTOR_ENDPOINT=https://your-collector.onrender.com:4318
-
Run installation:
./install.sh
If you prefer to enter values during installation:
-
Copy Wrapper to Pi:
# On your development machine: scp -r raspberry-pi-client-wrapper [email protected]:~/
-
Run Installation Script:
ssh [email protected] cd ~/raspberry-pi-client-wrapper chmod +x install.sh ./install.sh
The installer will:
- Check system compatibility
- Install system dependencies (Python, ALSA, audio libraries)
- Clone the Xavier repository
- Create Python virtual environment
- Install Python requirements
- Prompt for configuration (Device ID, OTEL endpoint, Environment)
- Setup OpenTelemetry Collector with systemd service
- Setup xavier systemd service (with auto-restart)
- Create .env template files
Installation takes 5-10 minutes depending on your Pi model and internet speed.
# Xavier logs (main application)
sudo journalctl -u xavier -f
# OpenTelemetry Collector logs
sudo journalctl -u otelcol -f
# Combined view
sudo journalctl -u xavier -u otelcol -fThe system is configured for maximum reliability:
- If
main.pycrashes or errors out, systemd automatically restarts it - No limit on restart attempts - it will keep trying indefinitely
- 10-second delay between restart attempts
- Restarts are logged in systemd journal
This ensures your device stays online even after:
- Python exceptions
- Network failures
- Temporary service disruptions
- System resource issues
When the Raspberry Pi boots:
- Network Wait:
xavier.servicewaits for network-online.target - OTEL Start: OpenTelemetry Collector starts (dependency)
- Launch Script:
launch.shis executed by systemd
The launch.sh script runs on every boot:
1. Check Internet Connection
├─ Ping 8.8.8.8 with retries
└─ Exit if no connection after 30 attempts
2. Update Code
├─ Clone repo if not exists
└─ Git pull latest changes if exists
3. Setup Python Environment
├─ Create venv if not exists
└─ Activate venv
4. Install Dependencies
└─ pip install -r requirements.txt
5. Verify Configuration
└─ Check .env file exists
6. Initialize ReSpeaker
└─ Apply tuning parameters
7. Run Client
└─ exec python main.py
| Service | Type | Purpose | Auto-Start | Auto-Restart |
|---|---|---|---|---|
otelcol.service |
System | OpenTelemetry Collector | Yes | Yes |
xavier.service |
System | Client Launcher & Updater | Yes | Yes (unlimited) |
The wrapper assumes you're using a ReSpeaker 4-Mic Array with hardware acoustic echo cancellation (AEC). The respeaker-init.sh script runs on every boot to configure optimal tuning parameters.
The following parameters are configured automatically:
- AGCGAIN: Microphone gain (default: 5.0)
- AGCONOFF: AGC freeze (default: 0 - frozen to prevent auto-adjustment)
- AECFREEZEONOFF: AEC adaptation (default: 0 - enabled)
- ECHOONOFF: Echo suppression (default: 1 - enabled)
You can override these via environment variables:
export RESPEAKER_AGCGAIN=5.0
export RESPEAKER_AGCONOFF=0
export RESPEAKER_AECFREEZEONOFF=0
export RESPEAKER_ECHOONOFF=1Before running the installer, clone the ReSpeaker tuning tools:
cd ~
git clone https://github.com/respeaker/usb_4_mic_array.gitRun active diagnostics in a service-like environment (transient systemd unit):
cd ~/raspberry-pi-client-wrapper
bash diagnostics/run-device-diagnostics.shBehavior:
- Stops
xavier(if currently active) - Sleeps between stop -> run -> restart steps
- Runs diagnostics using
systemd-run --wait --collect - Restarts
xavierautomatically on exit (including failures)
Optional tuning:
# Increase inter-step sleep and timeout (seconds)
SLEEP_BETWEEN_STEPS=5 DIAG_TIMEOUT_SECONDS=180 \
bash diagnostics/run-device-diagnostics.sh --strictReports are written to:
~/raspberry-pi-client-wrapper/diagnostics/reports/device-diag-<timestamp>.json
cd ~/raspberry-pi-client-wrapper/xavier/app
git pull origin main
sudo systemctl restart xaviercd ~/raspberry-pi-client-wrapper/xavier/app
source venv/bin/activate
pip install -r requirements.txt --force-reinstall# Stop services
sudo systemctl stop xavier
sudo systemctl stop otelcol
# Remove cloned repository
rm -rf ~/raspberry-pi-client-wrapper/xavier
# Restart (will re-clone)
sudo systemctl start xavierCheck logs:
sudo journalctl -u xavier -n 50View restart history:
# See how many times the service has restarted
sudo systemctl status xavier
# Watch for restart events in real-time
sudo journalctl -u xavier -fCommon issues:
.envfile not configured- No internet connection
- Python dependencies failed to install
- Invalid credentials
- Repeated crashes (check Python error messages in logs)
List ALSA devices:
aplay -l # List playback devices
arecord -l # List capture devicesTest speaker:
speaker-test -c2 -t wavTest microphone:
arecord -d 5 test.wav && aplay test.wavCheck status:
sudo systemctl status otelcol
sudo journalctl -u otelcol -n 50Validate config:
sudo /usr/local/bin/otelcol --config=/etc/otelcol/config.yaml validateForce update:
cd ~/raspberry-pi-client-wrapper/xavier/app
git fetch origin main
git reset --hard origin/main
sudo systemctl restart xavierCheck service status:
sudo systemctl is-enabled xavier
sudo systemctl is-enabled otelcolRe-enable:
sudo systemctl enable xavier
sudo systemctl enable otelcol
sudo systemctl daemon-reloadTo run the client manually (not as a service):
# Stop the service
sudo systemctl stop xavier
# Activate venv and run
cd ~/raspberry-pi-client-wrapper/xavier/app
source venv/bin/activate
python main.py
# When done, restart service
sudo systemctl start xavierTo completely remove the wrapper and all services:
cd ~/raspberry-pi-client-wrapper
./uninstall.shcd ~/raspberry-pi-client-wrapper
./uninstall.sh --auto-yes
# or
./uninstall.sh -yThe uninstall script will:
- Stop all services (xavier, otelcol)
- Disable all services
- Remove service files from systemd
- Remove OpenTelemetry Collector (binary, configs, data)
- Remove cloned repository and virtual environment
- Prompt to remove wrapper directory (optional)
- Prompt to remove cached downloads (optional)
- Prompt to remove system packages (optional)
- Prompt to reboot (optional)
Always removed:
- All systemd services
- OpenTelemetry Collector
- Cloned Xavier repository
- Python virtual environment
Optional (prompted):
- Wrapper directory with scripts
- System packages (pip, alsa-utils, etc.)
Preserved:
- System journal logs (can be manually cleared)
- URL:
https://github.com/harmonicalabs/xavier.git - Branch: Configurable via
GIT_BRANCHin.env(default:main) - Clone Location:
~/raspberry-pi-client-wrapper/xavier/ - Authentication: SSH access/deploy key required
- Wrapper:
~/raspberry-pi-client-wrapper/ - Client:
~/raspberry-pi-client-wrapper/xavier/app/ - Venv:
~/raspberry-pi-client-wrapper/xavier/app/venv/ - Client .env:
~/raspberry-pi-client-wrapper/xavier/app/.env - Cache:
~/raspberry-pi-client-wrapper/otel/.cache/(OpenTelemetry tarball) - OTEL Config:
/etc/otelcol/config.yaml - OTEL Env:
/etc/otelcol/otelcol.env
- Xavier:
/etc/systemd/system/xavier.service - OTEL Collector:
/etc/systemd/system/otelcol.service
The installer caches downloaded files to speed up reinstallations:
Location: ~/raspberry-pi-client-wrapper/otel/.cache/
What's cached:
- OpenTelemetry Collector tarball (~40MB)
Benefits:
- First installation: Downloads from internet
- Subsequent installations: Uses cached file (10x faster)
- Works offline after first download
- Preserves bandwidth
Cache management:
# Check cache size
du -sh ~/raspberry-pi-client-wrapper/otel/.cache
# Clear cache manually
rm -rf ~/raspberry-pi-client-wrapper/otel/.cache
# Uninstaller asks if you want to remove cache
# (Keeping it speeds up future reinstalls)If you encounter issues:
- Check service logs with
journalctl - Verify configuration files are correct
- Ensure internet connectivity
- Check system resources (disk space, memory)
Copyright © 2025. All rights reserved.