Helper Scripts Reference
Complete list of all helper scripts on your Batocera device and what they do.
π Location
All scripts are in: /userdata/voice-assistant/
Production Scripts (Use These!)
voice_assistant_wake.py (8.7K)
Purpose: Main wake word voice assistant
What it does:
- Listens continuously for βHey Jarvisβ wake word
- Records 5 seconds after wake word detection
- Transcribes with whisper.cpp
- Gets LLM response from Ollama
- Speaks response via Piper TTS
- Returns to listening mode automatically
Usage:
cd /userdata/voice-assistant
python3 voice_assistant_wake.py
Requirements:
- whisper-cli and all .so libraries
- hey_jarvis.onnx wake word model
- Python libraries: sounddevice, scipy, numpy, ollama, openwakeword
- Ollama running with llama3.2 model
voice_assistant_button.py (7.1K)
Purpose: Button-triggered voice assistant
What it does:
- Waits for button press on GPIO 23
- LED on GPIO 25 blinks during operation
- Records 5 seconds after button press
- Transcribes with whisper.cpp
- Gets LLM response from Ollama
- Speaks response via Piper TTS
Usage:
cd /userdata/voice-assistant
python3 voice_assistant_button.py
Requirements:
- whisper-cli and all .so libraries
- Button wired to GPIO 23
- LED wired to GPIO 25 (optional)
- Python libraries: sounddevice, scipy, numpy, ollama
- Ollama running with llama3.2 model
Setup Scripts
setup-voice-assistant.sh (6.9K)
Purpose: Initial setup and model downloads
What it does:
- Creates directory structure (/userdata/voice-assistant/)
- Downloads required models:
- Whisper model (ggml-base.en.bin)
- Wake word model (hey_jarvis.onnx)
- Voice model (en_US-amy-medium.onnx)
- Downloads and installs Piper TTS
- Creates environment setup script (setup-env.sh)
- Checks for whisper-cli (but doesnβt compile it)
- Provides clear instructions for manual steps
Usage:
cd /userdata/voice-assistant
bash setup-voice-assistant.sh
IMPORTANT: This script sets up everything EXCEPT:
- whisper.cpp compilation (must be done on Mac with Docker)
- Python library installation (must be copied to lib/)
- Ollama installation (separate process)
Run this on a clean Pi to download all models.
start.sh (3.4K)
Purpose: Convenient startup script with error checking
What it does:
- Sets up environment variables
- Starts Ollama if not running
- Checks for required models
- Validates whisper-cli and libraries exist
- Runs either wake word or button mode
- Provides clear error messages if something is missing
Usage:
cd /userdata/voice-assistant
# Start wake word mode (default)
bash start.sh
# Or explicitly
bash start.sh wake
# Start button mode
bash start.sh button
Benefits:
- Automatic Ollama startup
- Clear error messages
- Validates all dependencies before starting
install-service.sh (4.0K)
Purpose: Install systemd service for auto-start on boot
What it does:
- Creates systemd service file
- Configures service to start on boot
- Allows choosing between wake word or button mode
- Creates Ollama dependency service if missing
- Enables and starts the service
Usage:
cd /userdata/voice-assistant
sudo bash install-service.sh
After installation, manage with:
# Start/stop
sudo systemctl start voice-assistant
sudo systemctl stop voice-assistant
# Check status
sudo systemctl status voice-assistant
# View logs
sudo journalctl -u voice-assistant -f
# Disable auto-start
sudo systemctl disable voice-assistant
setup-env.sh (Created by setup-voice-assistant.sh)
Purpose: Set environment variables for voice assistant
What it does:
- Sets LD_LIBRARY_PATH to include voice assistant directory
- Sets PYTHONPATH to include lib/ directory
Usage:
cd /userdata/voice-assistant
source setup-env.sh
python3 voice_assistant_wake.py
Note: start.sh does this automatically, so you usually donβt need to run this manually.
π Optional/Utility Scripts
create_beep.sh (753B)
Purpose: Create placeholder sound files
What it does:
- Creates empty placeholder .wav files in sounds/ directory
- These are placeholders for future sound effects
Usage:
bash create_beep.sh
Note: Not essential - the voice assistant works without these.
Complete File Inventory
Current State of /userdata/voice-assistant/
/userdata/voice-assistant/
βββ voice_assistant_wake.py β Main wake word script (8.7K)
βββ voice_assistant_button.py β Main button script (7.1K)
βββ whisper-cli β STT binary (compiled for Pi 5)
βββ libwhisper.so.1 β Required library
βββ libggml.so.0 β Required library
βββ libggml-base.so.0 β Required library
βββ libggml-cpu.so.0 β Required library
βββ
βββ setup-voice-assistant.sh π οΈ Setup script (6.9K)
βββ start.sh π οΈ Startup script (3.4K)
βββ install-service.sh π οΈ Service installer (4.0K)
βββ setup-env.sh π οΈ Environment setup (auto-created)
βββ
βββ create_beep.sh π Optional utility (753B)
βββ
βββ README.md π Project overview
βββ setup-guide.md π Complete setup instructions
βββ wake-word-working.md π Wake word breakthrough details
βββ wrong-assumptions.md π Lessons learned
βββ
βββ models/
β βββ hey_jarvis.onnx π― Wake word model
β βββ ggml-base.en.bin π― Whisper model
β βββ en_US-amy-medium.onnx π― Piper voice model
βββ
βββ piper/
β βββ piper π£οΈ TTS binary
βββ
βββ lib/ π Python libraries
β βββ sounddevice/
β βββ scipy/
β βββ numpy/
β βββ ollama/
β βββ openwakeword/
βββ
βββ temp/ π Temporary audio files
Quick Start Workflows
Fresh Install on New Pi
# 1. Run setup to download models
bash setup-voice-assistant.sh
# 2. Compile whisper.cpp on your Mac (see setup-guide.md Section 5)
# Then copy whisper-cli and .so files to Pi
# 3. Copy Python libraries to lib/
# 4. Install Ollama (see setup-guide.md Section 1)
# 5. Test
bash start.sh
Daily Usage
# Wake word mode
bash start.sh
# Button mode
bash start.sh button
# Or directly
python3 voice_assistant_wake.py
python3 voice_assistant_button.py
Enable Auto-Start
sudo bash install-service.sh
# Choose mode (wake or button)
# Service will start on every boot
Important Notes
Whatβs Missing from Scripts
The helper scripts do not and cannot do these things (must be done manually):
- Compile whisper.cpp - Must be done on Mac with Docker (see setup-guide.md)
- Install Python libraries - Must be copied to
lib/directory - Install Ollama - Separate download and installation
These are documented in setup-guide.md with detailed instructions.
What the Scripts Do Well
The helper scripts excel at:
- β Downloading models (whisper, wake word, voice)
- β Installing Piper TTS
- β Setting up directory structure
- β Validating dependencies
- β Managing startup and services
- β Providing clear error messages
π§ Script Comparison
| Script | Purpose | Run Once? | Interactive? | When to Use |
|---|---|---|---|---|
| setup-voice-assistant.sh | Initial setup | β Yes | β οΈ Prompts | First install |
| start.sh | Start assistant | β No | β No | Every time you want to run |
| install-service.sh | Auto-start setup | β Yes | β Yes | Want boot-time startup |
| setup-env.sh | Environment vars | β No | β No | Manual Python execution |
| create_beep.sh | Sound placeholders | β Yes | β No | Optional customization |
π Best Practices
- Use
start.shinstead of running Python directly - it validates everything - Run
setup-voice-assistant.shonly once - it downloads models you keep - Use
install-service.shif you want the assistant to always run - Check
setup-guide.mdif anything fails - it has detailed troubleshooting - Read
wrong-assumptions.mdif youβre debugging - it documents common mistakes
π Troubleshooting
βwhisper-cli not foundβ
- You need to compile whisper.cpp on your Mac
- See setup-guide.md Section 5
βModule not foundβ errors
- Python libraries are missing from
lib/ - Copy them from a working system
βOllama not runningβ
- Run
bash start.shinstead - it starts Ollama automatically - Or manually:
/userdata/ollama/bin/ollama serve &
Wake word not detecting
- Check audio:
arecord -D plughw:0,0 -r 16000 -f S16_LE -d 3 /tmp/test.wav - Verify levels: Speak clearly 6-12 inches from mic
- Check model:
ls -la models/hey_jarvis.onnx
π Summary
You now have a complete, clean set of helper scripts:
- 2 production scripts (wake + button)
- 4 setup/utility scripts (setup, start, service install, env)
- 4 documentation files (README, SETUP_GUIDE, WAKE_WORD, WRONG_ASSUMPTIONS)
- All temporary/failed attempts cleaned up
- All scripts updated to reflect the working implementation
Everything is ready to use and properly documented! π