I wanted to see how far I could get with local voice control without building another giant AI application. So I gave myself a slightly silly constraint: can I make the whole thing fit into one Python file?
It turns out the answer is yes. And once it worked, I had a tiny system that could listen to something like:
"Turn off the kitchen light."
...turn that speech into text, figure out what I meant, and publish an MQTT message to my home automation system. Then I pushed the experiment a little further:
"Send email to ana at kickit.com with text hi ana can we meet tomorrow at 9am. Just tell me if that time works for you. Remember to bring the documents we discussed yesterday, please. Thank you see you tomorrow. have a great day."
That one actually sends an email. No cloud API. No mobile application. No complicated frontend. No huge collection of services running in containers. Just a Python process, a browser, a local speech model, a small local LLM agent, MQTT, and SMTP.
And yes, putting all of that into a single Python file is probably not something I would recommend for a production system. That is not really the point. This is an experiment. I wanted to understand how small a local speech-to-action system could be, what the individual pieces actually look like, and whether the whole thing could run comfortably on something like a Raspberry Pi.
01. The idea
Voice assistants are everywhere, but most of them depend on the cloud. For this experiment, I wanted to flip that around. The goal was a small, self-contained speech-to-action pipeline that runs locally on my own machine—or potentially on a small board such as a Raspberry Pi or Orange Pi.
The basic interaction is intentionally simple:
hold button
↓
say something
↓
release button
↓
speech → text → intent → action
For example: "turn off the kitchen light" becomes an MQTT message. Or:
"send email to ana at kickit.com with text hi" becomes an actual email.
The whole application—server, speech recognition, intent routing, tools, and web frontend—lives in a single Python file. That constraint is partly practical and partly just fun. Sometimes it is useful to deliberately make a project smaller than it needs to be.
02. How it all fits together
Before diving into the code, here is the complete architectural dataflow:
Browser microphone (WebM Blob)
│
│
POST /process-audio
│
│
faster-whisper (CTranslate2 INT8)
speech → text
│
│
"turn off the kitchen light"
│
├───────────────┐
│ │
│ │
deterministic local LLM agent
email parser (cactus-needle)
│ │
│ │
│ MQTT / email tool
│ │
└───────┬───────┘
│
action
┌───────┴───────┐
│ │
MQTT Broker SMTP Relay
(Mosquitto) (Local/Remote)
│
│
ESP32-S3 Board
(WS2812 NeoPixel)
There are three main pieces here:
- Speech recognition:
faster-whispertakes the audio recording and turns it into text using quantized INT8 weights on the CPU. - Intent routing:
cactus-needleacts as the local "brain". It receives the transcript and decides which tool should handle it. - Actions: Two dedicated tools:
control_home_systempublishes an MQTT message, andsend_emailsends an email through SMTP.
Sometimes the LLM does not do what you expect: it might refuse an obvious command, misunderstand a parameter, or produce an incomplete result. For a chatbot, that is annoying; for something that physically switches hardware on or off, it is critical. The application incorporates deterministic regex safeguard parsers that capture structured commands if the LLM refuses or stumbles.
03. The stack — and why I kept it small
The target hardware is not an expensive cloud server with 64 GB of RAM. The whole idea is to see whether this can live comfortably on something like a Raspberry Pi or Orange Pi. The design philosophy is simple: keep it light, keep it fast, avoid bloated runtimes.
| Component | What it is | Why this one |
|---|---|---|
| FastAPI | Async Python web framework | Lightweight way to serve the UI and API endpoints without heavy overhead |
| Uvicorn | ASGI server | Runs FastAPI with high concurrency and very little ceremony |
| faster-whisper | CTranslate2 implementation of Whisper | Local speech-to-text with INT8 CPU execution, 4x faster than vanilla PyTorch |
| cactus-needle | Lightweight local LLM agent | Runs on-device without a cloud round-trip, using function tools |
| paho-mqtt | Python MQTT client | Battle-tested, lightweight asynchronous MQTT pub/sub client |
| Mosquitto | MQTT broker | Standard broker consuming minimal memory, ideal for home automation |
| smtplib / email.message | Python standard library | Sends emails directly via SMTP without introducing third-party packages |
| Plain HTML/JS | Embedded frontend | Zero-build single string template: no React, bundlers, or 200MB node_modules |
| MicroPython + ESP32-S3 | Tiny MQTT hardware subscriber | Moves the final action onto physical hardware without running another server |
| WS2812 NeoPixel | Addressable RGB LED | A simple, visible indicator to prove that an MQTT command arrived |
The heaviest component is Whisper. For this experiment, the small model
with INT8 compute is an ideal compromise between accuracy and resource usage. Commands are short and
predictable, so there is no need for huge 1.5B parameter models.
04. Setup and requirements
The project assumes an MQTT broker is available on your local network. On macOS:
brew install mosquitto
brew services start mosquitto
On Debian-based systems such as Raspberry Pi OS or Armbian:
sudo apt update && sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable --now mosquitto
Then install the Python dependencies:
pip install "fastapi" "uvicorn" "faster-whisper" "cactus-needle==3.0.1" "paho-mqtt"
The project pins cactus-needle==3.0.1 for practical stability: newer
releases occasionally reference engine wheels not yet published on Hugging Face, which causes startup
crashes. The first run automatically downloads the Whisper model and the needle engine, caching them
locally in ~/.cache/huggingface.
4.1 Adding a real device: the ESP32-S3 endpoint
Publishing MQTT messages into the broker is great, but having a physical device react brings the project
to life.
In the repository, under esp32s3_neopixel/, is a tiny MicroPython
subscriber for an ESP32-S3.
It connects to WiFi, subscribes to home/neopixel_led/command, and drives
the onboard WS2812 LED.
The architecture maintains clean boundary separation:
Voice → Whisper (PC/Pi) → intent/tool → MQTT → ESP32-S3 (Microcontroller) → LED
Hardware configuration is segregated into its own file:
cp esp32s3_neopixel/config.example.py esp32s3_neopixel/config.py
# edit config.py with your WiFi credentials, broker IP, and LED pin
If your board needs a fresh MicroPython installation or you want to automate file transfers over USB
serial, you can flash the runtime with esptool.py and deploy your scripts
with adafruit-ampy (detailed terminal commands covered in Section 10.9).
05. Running the server
For immediate local testing on your development workstation:
python3 app.py
Then open your browser at http://localhost:8000.
Modern browsers (Chrome, Safari, Firefox) restrict microphone access (getUserMedia) strictly to secure contexts (localhost or https://). If you access the
server from a phone or another machine across your LAN, plain HTTP will be rejected.
The application provides a built-in HTTPS flag that generates a self-signed certificate into ./certs/ via OpenSSL:
python3 app.py --https
Navigate to https://<your-lan-ip>:8443, accept the self-signed
certificate warning, and grant microphone access.
06. Deep-dive code walkthrough
Let's walk through every functional block of app.py. The goal is to see
how each piece
cooperates to deliver end-to-end responsiveness within a single file.
6.1 Imports and logging
import io, json, logging, os, re, smtplib, subprocess, sys
import email.message
from fastapi import FastAPI, UploadFile, File, HTTPException
from faster_whisper import WhisperModel
import needle
import paho.mqtt.client as mqtt
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s")
logger = logging.getLogger("VoiceMQTT")
Notice how minimal the non-standard imports are: FastAPI, faster-whisper, needle, and paho-mqtt. Everything else comes from standard Python.
6.2 MQTT client initialization and background loop
MQTT configuration is driven by environment variables with fallback defaults. The client starts its network loop in a background thread:
MQTT_BROKER = os.environ.get("MQTT_BROKER", "127.0.0.1")
MQTT_PORT = int(os.environ.get("MQTT_PORT", 1883))
MQTT_TOPIC_PREFIX = os.environ.get("MQTT_TOPIC_PREFIX", "home/")
mqtt_client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2)
mqtt_client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60)
mqtt_client.loop_start()
Using loop_start() prevents network delays on the broker from blocking
FastAPI's ASGI event loop. Commands are published with QoS 1 to guarantee at-least-once delivery.
6.3 Whisper configuration, INT8 compute, and persistent settings
WHISPER_DEVICE = os.environ.get("WHISPER_DEVICE", "cpu")
WHISPER_COMPUTE_TYPE = os.environ.get("WHISPER_COMPUTE_TYPE", "int8")
WHISPER_INITIAL_PROMPT = os.environ.get(
"WHISPER_INITIAL_PROMPT",
"Turn on the lights. Turn off the fan. Home automation voice command."
)
whisper_model = WhisperModel(
"small",
device=WHISPER_DEVICE,
compute_type=WHISPER_COMPUTE_TYPE
)
Settings are stored in settings.json and editable at runtime through the
web interface via GET /settings and POST /settings.
6.4 The MQTT tool: _dispatch and the allowlist
The LLM does not interact directly with the socket. Instead, it interacts via a registered tool:
@needle.tool
def control_home_system(device: str, status: str):
"""Control a home automation device by publishing an MQTT command."""
device_clean = device.lower().replace(" ", "_")
status_clean = status.lower().strip()
return _dispatch(device_clean, status_clean)
def _dispatch(device_clean: str, status_clean: str):
allowed = settings.get("allowed_devices") or []
if allowed and device_clean not in allowed:
return {
"status": "refused",
"reason": f"device '{device_clean}' is not in the configured allowlist",
"allowed_devices": allowed
}
topic = f"{MQTT_TOPIC_PREFIX}{device_clean}/command"
payload = json.dumps({
"device": device_clean,
"action": status_clean,
"triggered_by": "voice_needle_hub"
})
mqtt_client.publish(topic, payload, qos=1)
return {"status": "ok", "topic": topic, "device": device_clean, "action": status_clean}
This is a crucial security barrier: the model suggests an action, but the Python application verifies whether the device is permitted.
6.5 The email tool: SMTP via standard library
Sending email does not require external SDKs. It uses Python's smtplib
and email.message, with spoken email normalization:
def _normalize_email_address(raw: str) -> str:
cleaned = raw.lower().strip()
cleaned = re.sub(r"\s+at\s+", "@", cleaned)
cleaned = re.sub(r"\s+dot\s+", ".", cleaned)
cleaned = re.sub(r"\s+", "", cleaned)
return cleaned
@needle.tool
def send_email(recipient: str, body: str):
"""Send an email to a specified recipient with a text message body."""
return _send_email(recipient, body)
Spoken phrases like "ana at kickit dot com" are automatically transformed
to [email protected] before verification and delivery.
6.6 Deterministic safeguard parsers
Regex parsers act as immediate gateways and fallback paths when the LLM hesitates:
def _parse_command(text: str):
m = re.search(r"(?:turn|switch|set)\s+(?:on|off)\s+(?:the\s+)?(.+)", text, re.IGNORECASE)
if m:
action = "on" if "on" in text.lower() else "off"
return m.group(1).strip(), action
return None, None
def _parse_email_command(text: str):
m = re.search(r"send\s+email\s+to\s+([^\s]+(?:@[^\s]+|\s+at\s+[^\s]+))\s+(?:with\s+text|saying|message)\s+(.*)", text, re.IGNORECASE)
if m:
return _normalize_email_address(m.group(1)), m.group(2).strip()
return None, None
6.7 The /process-audio endpoint
The core request handler orchestrates transcription, intent parsing, and tool dispatch:
@app.post("/process-audio")
async def process_audio(file: UploadFile = File(...)):
audio_bytes = await file.read()
segments, info = whisper_model.transcribe(
io.BytesIO(audio_bytes),
beam_size=5,
condition_on_previous_text=False,
vad_filter=True,
no_speech_threshold=0.6
)
transcript = " ".join([segment.text for segment in segments]).strip()
# Step 1: Check deterministic email pattern first
to_addr, body = _parse_email_command(transcript)
if to_addr and body:
result = _send_email(to_addr, body)
return {"transcript": transcript, "source": "deterministic_email", "result": result}
# Step 2: Run local LLM agent with fresh state
agent.reset()
agent_output = agent.run(transcript, strict=False)
# Step 3: Check fallback parser if agent returned no actions
if not agent_output.has_actions:
device, action = _parse_command(transcript)
if device and action:
result = _dispatch(device.replace(" ", "_"), action)
return {"transcript": transcript, "source": "fallback_parser", "result": result}
return {"transcript": transcript, "source": "needle_agent", "output": agent_output}
Calling agent.reset() before every command is vital: voice commands are
stateless discrete operations, and preserving previous dialogue history could bias future classifications.
6.8 Embedded web UI
The frontend is served from a raw multi-line HTML string:
Hold Button Pressed ──navigator.mediaDevices.getUserMedia({ audio: true })
│
│
MediaRecorder.start()
│
Hold Button Released ──MediaRecorder.stop()
│
│
Blob (audio/webm)
│
│
fetch('/process-audio', { method: 'POST', body: formData })
│
│
Render JSON Output in UI
07. Running your first experiments
Now for the fun part: bench testing the pipeline across different modalities and inspecting every packet along the wire.
Sending an Email via Voice
Spoken Utterance: "Send email to ana at kickit.com with text hi ana can we meet tomorrow at 9am. Just tell me if that time works for you. Remember to bring the documents we discussed yesterday, please. Thank you see you tomorrow. have a great day."
The deterministic parser intercepts the email pattern before invoking the LLM, perfectly preserving the multi-sentence message body without any truncation or hallucinated changes.
MQTT Home Automation: Living Room Lights
Spoken Utterance: "Turn off the living room lights"
The agent parses the spoken command, normalizes the device identifier to living_room_lights, and publishes a QoS 1 payload onto home/living_room_lights/command.
Hardware Control: Set ESP32-S3 NeoPixel to Red
Spoken Utterance: "Set the neopixel led to red"
action: red)
The payload reaches the ESP32-S3 board over WiFi. The MicroPython script decodes action: red, maps it to (255, 0, 0), and
drives the onboard WS2812 pin to illuminate physical red.
Hardware Control: Turn NeoPixel Off
Spoken Utterance: "Turn off the neopixel led"
action: off)
The ESP32-S3 receives the off instruction and drives (0, 0, 0) into the
NeoPixel registers, extinguishing the physical LED instantly.
Testing without a microphone
You don't need a live microphone to test the speech pipeline. On macOS, you can synthesize audio and curl the endpoint:
say -o /tmp/c.aiff "turn on the kitchen light"
afconvert -f WAVE -d LEI16@16000 /tmp/c.aiff /tmp/c.wav
curl -X POST -F "file=@/tmp/c.wav;type=audio/wav" http://localhost:8000/process-audio | python3 -m json.tool
On Linux:
espeak-ng -w /tmp/c.wav "turn on the kitchen light"
curl -X POST -F "file=@/tmp/c.wav;type=audio/wav" http://localhost:8000/process-audio
08. What can go wrong?
Working with edge speech models and microcontrollers brings interesting edge cases. Here are the most common issues and how to resolve them:
Server crashes after "Initializing Needle Engine..."
pip show cactus-needle. Pin
it strictly to cactus-needle==3.0.1. If a stale .no_exist lockfile exists in ~/.cache/huggingface, delete it so the wheel can re-download.
The agent repeats or hallucinates the previous command
agent.reset() is called prior to each invocation in /process-audio. The agent context must be purged so consecutive commands
remain strictly independent.
Microphone access denied in browser
python3 app.py --https when
accessing across a LAN. Modern browsers disable audio capture over insecure HTTP.
MQTT command published but rejected ("status": "refused")
settings.json. If allowed_devices has any entries, only listed identifiers are permitted.
Add your target device (e.g., neopixel_led) via the Settings modal.
09. Why this fits on a single-board computer
The system was architected to stay inside modest hardware limits. On a Raspberry Pi 4/5 or Orange Pi 3B:
- INT8 Whisper Quantization: Reduces memory consumption drastically while using CTranslate2 CPU SIMD optimizations.
- Memory Footprint: The entire Python runtime (FastAPI + Whisper Small + Needle + Paho) idles at roughly 650 MB – 850 MB of RAM.
- No Node.js Runtime: Embedding the frontend eliminates frontend build stages, Node engines, and heavy web servers.
- Hardware Isolation: Offloading physical GPIO control to an ESP32-S3 keeps the Pi free from timing-sensitive microcontroller loops.
[Unit]
Description=Voice Controlled Home Hub
After=network.target mosquitto.service
Requires=mosquitto.service
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/voice-hub
ExecStart=/usr/bin/python3 app.py --https
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target
10. The MicroPython client, code by sections
While the Python hub acts as the voice and intent gateway, the ESP32-S3 acts as the physical listener.
It subscribes to home/neopixel_led/command, decodes whatever payload the
hub published, and drives the onboard WS2812 RGB LED.
Real bench captures showing the physical response of the ESP32-S3 onboard WS2812 addressable RGB LED when issued discrete voice and MQTT commands:
Let's review the MicroPython implementation running on the board:
10.1 config.example.py vs config.py
WIFI_SSID = "your_wifi"
WIFI_PASS = "your_password"
MQTT_BROKER = "192.168.1.50"
MQTT_PORT = 1883
DEVICE_NAME = "neopixel_led"
MQTT_TOPIC = "home/" + DEVICE_NAME + "/command"
NEOPIXEL_PIN = 48
LED_COUNT = 1
LED_OFF = (0, 0, 0)
DEFAULT_ON_COLOR = (255, 255, 255)
COLORS = {
"red": (255, 0, 0),
"green": (0, 255, 0),
"blue": (0, 0, 255),
"yellow": (255, 255, 0),
"cyan": (0, 255, 255),
"magenta": (255, 0, 255),
"white": (255, 255, 255),
}
10.2 Imports and NeoPixel setup
import time, json, network, machine
from machine import Pin
from neopixel import NeoPixel
from umqtt.simple import MQTTClient
from config import WIFI_SSID, WIFI_PASS, MQTT_BROKER, MQTT_PORT, DEVICE_NAME
from config import MQTT_TOPIC, NEOPIXEL_PIN, LED_COUNT, LED_OFF, DEFAULT_ON_COLOR, COLORS
np = NeoPixel(Pin(NEOPIXEL_PIN), LED_COUNT)
current_color = DEFAULT_ON_COLOR
10.3 Single write gate: set_led
def set_led(color):
global current_color
current_color = color
np[0] = color
np.write()
Channeling every physical LED state change through a single function guarantees auditability and prevents race conditions.
10.4 Flexible color and action parser: parse_color
def parse_color(value):
value = (value or "").strip().lower()
if value in ("on", "up", "brighten", "1", "true"):
return True
if value in ("off", "down", "dim", "0", "false"):
return False
return COLORS.get(value)
This parser normalizes synonyms across home automation verbs and color palettes simultaneously.
10.5 MQTT callback handler: handle_command
def handle_command(topic, payload):
text = payload.decode("utf-8", "replace").strip()
try:
data = json.loads(text)
color = parse_color(data.get("color"))
if color is None:
color = parse_color(data.get("action"))
except (ValueError, AttributeError):
color = parse_color(text)
if color is False:
set_led(LED_OFF)
elif color is True:
set_led(current_color if current_color != LED_OFF else DEFAULT_ON_COLOR)
elif isinstance(color, tuple):
set_led(color)
10.6 Resilient WiFi station connection
def connect_wifi():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
wlan.connect(WIFI_SSID, WIFI_PASS)
for _ in range(30): # ~15 s budget
if wlan.isconnected():
break
time.sleep(0.5)
if not wlan.isconnected():
raise RuntimeError("WiFi connection failed")
10.7 Main MQTT loop and watchdog reset
def connect_mqtt():
client_id = "esp32s3_neopixel_" + str(machine.unique_id().hex())
client = MQTTClient(client_id, MQTT_BROKER, port=MQTT_PORT, keepalive=60)
client.connect()
client.set_callback(handle_command)
client.subscribe(MQTT_TOPIC)
return client
def main():
connect_wifi()
client = connect_mqtt()
while True:
try:
client.wait_msg()
except OSError:
time.sleep(2)
try:
client = connect_mqtt()
except OSError:
machine.reset()
Using machine.unique_id().hex() guarantees client ID uniqueness on the
broker, while wait_msg() blocks without burning CPU cycles. A dropped
connection gets two seconds of patience, followed by a fresh connect and re-subscribe cycle; if that
fails, machine.reset() reboots the board cleanly into a known state.
10.8 The missing line of symmetry: Color command pass-through
One detail worth noting: the MicroPython subscriber is already equipped to handle color words (such as
red, green, blue) via either an explicit color key or an
action field in the MQTT payload.
However, the hub's default control_home_system tool initially emitted
binary on / off statuses. Teaching the
voice hub to pass color words directly through as the action string allows spoken commands like "set
the neopixel led to green" or "set the neopixel led to red" to be translated directly into
RGB tuples on the microcontroller without changing a single line of firmware on the board.
10.9 Flashing MicroPython with esptool & uploading
files with adafruit-ampy
If your ESP32-S3 is fresh out of the antistatic bag or currently running Arduino C++ firmware, getting it
ready for this project involves two quick terminal phases: flashing the MicroPython runtime with
Espressif's official esptool.py, and transferring your Python scripts
onto the flash filesystem using adafruit-ampy.
Flashing MicroPython with esptool.py
Install esptool and connect the ESP32-S3 to your workstation via USB-C.
Identify the serial device (/dev/cu.usbmodem* on macOS, /dev/ttyACM0 or /dev/ttyUSB0 on Linux).
# Install Espressif's ROM bootloader utility
pip install --upgrade esptool
# Step 1A: Erase existing flash memory (hold BOOT button if auto-reset fails)
esptool.py --port /dev/cu.usbmodem1234 erase_flash
# Step 1B: Flash official MicroPython ESP32-S3 binary at offset 0x0
# (Download the generic S3 firmware from https://micropython.org/download/ESP32_GENERIC_S3/)
esptool.py --chip esp32s3 --port /dev/cu.usbmodem1234 --baud 460800 write_flash -z 0x0 ESP32_GENERIC_S3-20240222-v1.22.2.bin
Unlike classic ESP32 boards that write firmware starting at offset 0x1000, the ESP32-S3 ROM bootloader requires the combined firmware image
to be written at memory offset 0x0.
Managing Files over Serial with adafruit-ampy
adafruit-ampy (Adafruit MicroPython Tool) communicates directly over serial with MicroPython's raw REPL. It allows you to create directories, upload files, download logs, and run scripts on the microcontroller without manual copy-pasting into terminal emulators.
# Install adafruit-ampy
pip install adafruit-ampy
# Export environment defaults to simplify terminal syntax
export AMPY_PORT=/dev/cu.usbmodem1234
export AMPY_BAUD=115200
export AMPY_DELAY=0.5 # Crucial buffer delay for USB CDC serial interfaces
# Step 2A: Upload configuration file and main runtime
ampy put esp32s3_neopixel/config.py /config.py
ampy put esp32s3_neopixel/main.py /main.py
# Step 2B: List files stored on the microcontroller flash filesystem
ampy ls
# Output:
# /config.py
# /main.py
# Step 2C: Run or test code interactively on the board
ampy run esp32s3_neopixel/main.py
# Step 2D: Soft-reset the board to boot /main.py at startup
ampy reset
To install the umqtt.simple library required for MQTT communication,
you can either install it directly over WiFi using mpremote:
mpremote mip install umqtt.simple
Or download simple.py from the official micropython-lib repository and upload it with ampy:
ampy mkdir /lib && ampy mkdir /lib/umqtt && ampy put simple.py /lib/umqtt/simple.py.
11. Where this experiment could go
The current system is intentionally compact, but the foundation opens up compelling upgrade paths:
- Bidirectional device state queries: Subscribing to state telemetry topics so you can ask "Are the kitchen lights already off?"
- Production SMTP alerting: Routing home server fault alerts and security notifications directly through the voice agent's email pipeline.
- Dynamic Whisper model scaling: Seamlessly switching between
tinyon battery nodes andmediumon workstation GPUs. - Wake-word integration: Adding an open-source wake-word engine (like openWakeWord) for hands-free operation.
- Headless audio streaming: Enabling external smart speakers or intercoms to stream
audio directly to
POST /process-audio. - Swapping actuators: Replacing the NeoPixel with relays, solenoids, or HVAC controllers with zero modifications to the hub.
12. What I actually like about this experiment
The most rewarding aspect of this project is not any single piece of new technology. Whisper is not new. MQTT is not new. SMTP is decades old. And routing intents through an LLM is well-established.
What is deeply satisfying is how short, transparent, and inspectable the entire chain becomes:
speech ──text ──intent ──tool ──real-world action
If something misbehaves, there is no black-box cloud service to blame. You can inspect the audio waveform, the Whisper transcript, the agent's intent tokens, the exact MQTT packet, and the ESP32 UART console. Everything is under your control.
13. Final thoughts
Was putting everything in one Python file a good idea? Probably not if you are architecting a massive enterprise platform. But as an engineering experiment? Absolutely.
It forced simplicity, eliminated runtime bloat, and answered the core engineering question: a capable, privacy-first local voice-to-action hub does not need to be huge. It is hackable, lightweight, and ready for you to adapt to your own smart home.
14. References — tools and libraries used
| Tool / Library | Official Documentation | Role in Architecture |
|---|---|---|
| FastAPI | fastapi.tiangolo.com | Asynchronous API routing and static frontend serving |
| Uvicorn | uvicorn.org | High-performance ASGI server |
| faster-whisper | github.com/SYSTRAN/faster-whisper | Local speech-to-text inference with INT8 quantization |
| cactus-needle | pypi.org/project/cactus-needle | Local LLM agent tool routing and execution |
| Paho MQTT | eclipse.org/paho | MQTT publisher with background event loop |
| Eclipse Mosquitto | mosquitto.org | Lightweight MQTT message broker |
| MicroPython | micropython.org | Embedded Python runtime for ESP32-S3 |
| umqtt.simple | github.com/micropython/micropython-lib | MicroPython MQTT client library |
| esptool | github.com/espressif/esptool | Espressif ROM bootloader utility for erasing and flashing MicroPython firmware |
| adafruit-ampy | github.com/scientifichackers/ampy | Adafruit MicroPython Tool for serial file transfers and command execution |
| mpremote | docs.micropython.org | CLI tool for flashing and package management on microcontrollers |
15. License & companion repository
All code for the voice hub and the ESP32-S3 MicroPython firmware is released under the open-source MIT License. Clone the companion repository to run the hub locally or flash your own board:
20+ years building industrial SCADA telemetries, microcontrollers, and autonomous AI-driven systems.
About Félix