Running LLMs on a Raspberry Pi 5
| assets | ||
| device-stuff | ||
| scripts | ||
| src/local_chat | ||
| systemd | ||
| .gitignore | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| temp_audio_source.mp3 | ||
Local LLM Chat Bot
A local voice-enabled chat bot running on DietPi (Raspberry Pi).
Prerequisites
- OS: DietPi is recommended. See device-stuff for configuration files (
diet-pi_config.txt,rpi_config.txt).
Installation
-
Run Setup Script This script installs system dependencies (apt), Ollama, Piper TTS, and downloads necessary models.
./scripts/setup.sh -
Create Python Environment It is recommended to use
--system-site-packagesto allow access to system-level libraries installed via apt (likepython3-lgpio).python3 -m venv --system-site-packages .venv source .venv/bin/activate pip install -r requirements.txt # If you have one, or install dependencies manually # Dependencies: ollama, fast-whisper, sounddevice, soundfile, numpy, gpiozero, piper-tts, fastapi, uvicorn, python-multipart # Note: local_chat.py dependencies are currently managed manually or via setup.sh hints.Note
: If you run into issues with
lgpioor audio, ensuring--system-site-packagesis used is often the fix.
Running the Bot
To run the chat bot manually:
source .venv/bin/activate
python3 src/local_chat/local_chat.py
Systemd Services (Autostart)
To configure the bot to start automatically on boot:
-
Install Service Files Run the startup setup script to copy systemd files to
/etc/systemd/system/.sudo ./scripts/setup_startup.sh -
Enable and Start Services
# Reload systemd sudo systemctl daemon-reload # Enable Ollama (Dependecy) sudo systemctl enable --now ollama # Enable Chat Bot sudo systemctl enable --now local-chat-bot -
Optional: Faster Whisper Server If you are using the separate Whisper server:
sudo systemctl enable --now faster-whisper-server
Project Structure
src/local_chat/: Python source code (local_chat.py,assistant.py, etc.)scripts/: Shell scripts for setup and maintenance.device-stuff/: Hardware/OS configuration files.assets/: Models and sounds.