Samar

Milo — ESP32 Voice Assistant

By Samar

What I built

I built Milo, a small voice assistant that lets me talk to an AI through an ESP32 device. I wanted my own personalized Alexa-like assistant: something I could plug in, wake up by saying “Hey Milo,” and ask questions.

I used a Waveshare ESP32-S3-AUDIO-Board with a microphone and speaker, and connected it to OpenAI’s Realtime API. In my demo, Milo responds to its name and starts answering my question about how the ESP32 works. It is still a prototype. The main problem I need to improve is what happens when I interrupt it.

Why I’m proud of it

I’ve built a number of projects, but this is one I’m particularly proud of. The part I like most is how small it is. After I upload the firmware, the code stays in the board’s flash memory. I can disconnect it from my programming setup and power it from a cable.

It still needs Wi-Fi, internet access, and an API key to have a conversation. The ESP32 handles the device’s audio and local commands; the conversational model runs through OpenAI’s service.

How I built it

The firmware is written in C using ESP-IDF. I used Codex to help write the code. This was one of the more complex coding projects I had worked on, with several pieces that needed to work together: recognizing commands, connecting to Wi-Fi, sending my voice to the API, and playing the response.

I configured Wi-Fi and the API connection, then uploaded the firmware to the board. Once powered on, Milo initializes its audio hardware, connects to Wi-Fi, and starts listening for local commands.

The local speech-recognition component uses ESP-SR MultiNet to recognize “Hey Milo” and “Stop Milo.” “Hey Milo” opens a Realtime conversation. “Stop Milo” tells the firmware to close it.

During a conversation, microphone audio goes to OpenAI over a secure WebSocket connection. The service detects speech turns and sends spoken responses back. Separate tasks and audio queues handle recording, transmission, and playback.

One technical detail is that the board’s audio path and the API use different sample rates. The firmware converts the microphone’s 16 kHz audio to 24 kHz for the API, then converts incoming speech back to 16 kHz for playback.

The code is organized into separate components. The speech driver handles local recognition, the Wi-Fi manager handles the network connection, and the Realtime agent manages the conversation and streamed audio. The main program connects those pieces.

Getting the audio formats to match

Connecting the microphone and speaker to the API involves more than sending bytes. The sample rate and channel layout have to match what each side expects.

The firmware converts audio in both directions and duplicates the returned mono samples into the board’s two playback channels. The code explains why this matters: without that duplication, consecutive mono samples are treated as a stereo frame, making speech play at roughly double speed.

Making interruptions work

The biggest problem I point out in my demo is interruption. When I interrupt Milo, it can stutter, glitch, or keep speaking instead of stopping cleanly.

The current code enables interruption on the API side and clears queued playback when it detects that the user has started speaking. It also has a separate command for ending the conversation. Those mechanisms are in place, but the behavior in my demo shows that there is still work to do. I don’t consider this problem solved.

Keeping setup practical

I wanted to be able to plug Milo in and use it without reconnecting it to a computer each time. Storing the firmware in flash and configuring Wi-Fi makes that possible on the configured network.

The prototype uses a local configuration for its network and API connection. I’d like to make that setup easier to change without rebuilding the firmware.

Where the project stands

My demo shows Milo waking up, greeting me, and beginning an answer to a spoken question. It also shows the limitation I still need to work on. I’m proud of getting a conversation running on such a small device, while being clear that it is not yet a finished assistant.

My next priority is improving interruption behavior so I can stop or redirect a response reliably. I want to show that progress in a future demo.

Demo

Demo video: Watch on YouTube