Happy, the AI hardware robot – understanding – speech to text
These are the steps to set up the speech to text converter process for the Building Happy, the AI hardware robot project to enable Happy to understand speech.
Happy’s speech-to-text works in two parts. The ESP32 records your voice and sends it over Wi-Fi to your PC, and Whisper turns it into text on the PC. Whisper is too big to run on the ESP32 itself.
For the latest instructions see speech-to-text\README.md in the repository.
Setup on the PC
Install Python 3.12:
- Open a PowerShell terminal
winget install Python.Python.3.12
- Verify the Python installation
py -3.12 --version
Create a virtual Python environment
- We will create a virtual environment and install PyTorch with GPU support. Virtual Python environments enable us to use different Python versions per project to avoid version conflicts
cd speech-to-text\brain
py -3.12 -m venv .venv
- Running Python from the terminal
- The Happy scripts call Python with the full path to use the correct environment. If you want to run Python scripts in the speech-to-text\brain directory, every time you open a new Terminal window activate the environment with
.venv\Scripts\Activate.ps1
- The Happy scripts call Python with the full path to use the correct environment. If you want to run Python scripts in the speech-to-text\brain directory, every time you open a new Terminal window activate the environment with
Install PyTorch with GPU support
- Open a new terminal in the
brainfolder. Install PyTorch with GPU support first; this command is for an Nvidia card:
.venv\Scripts\python.exe -m pip install torch --index-url https://download.pytorch.org/whl/cu126
- Test the Pytorch installation
.venv\Scripts\python.exe -c "import torch; print(torch.__version__, torch.cuda.is_available())"
- Expected: something like
2.x.x+cu126 True.
Install Whisper (and Kokoro)
.venv\Scripts\python.exe -m pip install -r requirements.txt
- Test the Wisper and Kokoro installation
.venv\Scripts\python.exe -c "import whisper, kokoro, soundfile; print('all good')"
- Expected: all good
Start the LM Studio server to run the AI model in the background
- In the terminal execute
& "$env:USERPROFILE\.lmstudio\bin\lms.exe" server start
- Test the server access
curl.exe http://localhost:1234/v1/models
- Expected a list of AI models
Test if Gemma answers
- In the terminal execute
'{"model":"google/gemma-4-26b-a4b-qat","messages":[{"role":"user","content":"Say hi in one sentence"}],"reasoning_effort":"none"}' | curl.exe http://localhost:1234/v1/chat/completions -H "Content-Type: application/json" --data-binary "@-"
- Expected: a JSON answer with
"content": "Hi there! ...". The first call can take up to a minute while the model loads.
Start the Happy server by hand
- In the terminal execute
cd speech-to-text\brain
.venv\Scripts\python.exe stt_server.py
- The first start downloads the models (Whisper ~460 MB, Kokoro ~330 MB, plus a small language pack), which takes a few minutes. Later starts take about 20 seconds. It’s ready when it prints:
Listening on http://0.0.0.0:8000 (POST /talk /stt /chat /say, GET /health) - Leave this window open to keep the server running
Let the ESP32 reach the server through Windows Firewall
- Run this in an admin PowerShell:
New-NetFirewallRule -DisplayName "Happy STT" -Direction Inbound -Protocol TCP -LocalPort 8000 -Action Allow
Optionally, test with any 16-bit WAV file before the robot is involved
- In a terminal execute
curl.exe -X POST -H "Content-Type: audio/wav" --data-binary "@test.wav" http://localhost:8000/stt
Setup on the ESP32
- Open the speech-to-text\firmware\stt_client\stt_client.ino file with the Arduino IDE
- At the top of the sketch, fill in
WIFI_SSID,WIFI_PASSandSTT_URL. For the URL, use your PC’s IPv4 address fromipconfig. - Upload it the same way you did
mic_test. - Open the Serial Monitor, set the speed to 115,200 baud
- Hold BOOT button on the ESP32 board, say something, and release the button to send the audio to the server.

Send the text to the AI model
Send the text from the reply to Gemma through LM Studio’s local server (Developer tab → Start Server). I left a comment at that spot in the sketch. Doing this on the PC side is easier than on the ESP32.
Enable the ML Studio Ai service
- Start LM Studio on the computer
- In the lower left corner click the gear icon

- On the Developer tab make sure the Developer mode is On, and Enable Local LLM Service

- Close the page with the X in the upper right corner

Set up the auto start of the AI servers
We will create a Scheduled Task that runs every time you log in, so no credentials are saved on the computer.
It starts 3 servers:
- stt_server.py – Python server to run Whisper, the speech to text converter. It receives audio clips from the ESP32, converts them to text, and passes them to LM Studio within the computer
- LM Studio server to function as Happy’s brain and generate the answers
- Kokoro – text to speech server to generate Happy’s voice
To set up the Scheduled Task
- Open a PowerShell terminal in the speech-to-text\brain folder
- Execute the command
powershell -ExecutionPolicy Bypass -File install_autostart.ps1 - To manually start the Scheduled Task from the command line without logging off and on, execute
Start-ScheduledTask -TaskName "Happy Brain" - To remove the Scheduled Task later when not needed anymore
powershell -ExecutionPolicy Bypass -File install_autostart.ps1 -Uninstall - To see what the speech to text server is doing, open
brain\logs\stt_server.log
Testing Speech to Text
Send an audio file from the computer
- We will generate an audio file from text. Open a PowerShell terminal and execute
Add-Type -AssemblyName System.Speech; $s = New-Object System.Speech.Synthesis.SpeechSynthesizer; $s.SetOutputToWaveFile("$PWD\test.wav"); $s.Speak('Hello Happy, how are you today?'); $s.Dispose() - The test.wav file is created in the current directory
- Send the test.wav file to the speech to text Python server
curl.exe -X POST -H "Content-Type: audio/wav" --data-binary "@test.wav" http://localhost:8000/stt - The response will contain Happy’s answer
{“text”: “Hello Happy, how are you today?”, “language”: “en”, “seconds_audio”: 2.98, “seconds_stt”: 0.47, “peak”: 0.947, “reply”: “I am doing great and feeling very energetic! Are you having a good day so far?”, “seconds_llm”: 3.07}
With the robot
- Open stt_client.ino and fill in your Wi-Fi details.
- Set
STT_URLtohttp://<your PC's IPv4 from ipconfig>:8000/stt. - Upload the sketch and open the Serial Monitor at 115200.
- Hold BOOT, speak, then release. You should see
Whisper: {"text": "...", "reply": "..."}.