esp32.diy

ESP32-S3 AI Voice Assistant with Gemini, STT and TTS

Oct 13, 2026 · 4 min read

Intermediate 46 stars 12 forks C++ MIT Updated 2026-07-24

Full wiring diagram showing the ESP32-S3 connected to the INMP441 microphone, MAX98357A amplifier, speaker and optional VL53L0X ToF sensor.

TL;DR This project turns an ESP32-S3 into a standalone AI voice assistant that listens through an I2S microphone, sends audio to Google Cloud Speech-to-Text, queries Gemini AI for a response, and plays back natural speech through an I2S amplifier and speaker. A dual-core architecture and persistent TLS connections cut the full round-trip time to around 20 seconds.
What you need
  • ESP32-S3 (with PSRAM)
  • INMP441 I2S Microphone
  • MAX98357A I2S Amplifier
  • 4–8Ω 3W Speaker
  • VL53L0X ToF Sensor (optional)
  • Breadboard
BoardESP32-S3 (PSRAM required)
FrameworkArduino IDE
LanguageC++
Cloud ServicesGoogle Cloud STT, Gemini AI, TTS
LicenseMIT
DifficultyIntermediate

What You Will Build

This project gives an ESP32-S3 a voice and a brain. You speak a question, the board records audio through an INMP441 I2S microphone, ships it over Wi-Fi to Google Cloud Speech-to-Text, forwards the transcript to Google Gemini for an intelligent reply, then converts that reply to natural speech with Google Cloud Text-to-Speech and plays it back through a MAX98357A amplifier and a small speaker.

An optional VL53L0X time-of-flight sensor acts as a proximity trigger — the assistant wakes automatically when someone steps close, so you do not need a button. All three cloud calls run in parallel across both ESP32-S3 cores, and TLS connections are kept alive between requests. The result is a full conversational loop in roughly 20 seconds end-to-end.

What You Need

Hardware

Software and accounts

Arduino libraries (install via Library Manager):

Typical use cases

Hands-Free AI Assistant

Place the device on a desk or workbench and use voice commands to get answers from Gemini without touching a keyboard, useful while your hands are occupied with a build.

Multilingual Voice Interface

By changing the TTS language setting in the sketch, the same hardware can serve as a spoken interface in different languages for kiosks, language-learning tools or accessibility aids.

Presence-Triggered Interaction

With the optional VL53L0X sensor fitted, the assistant activates only when someone walks up, making it practical for reception desks, museum exhibits or smart mirrors.

Cloud AI Prototyping Platform

The clean separation between audio I/O and cloud API calls makes this a useful starting point for any ESP32-S3 project that needs to call Google Cloud services over TLS with low latency.

Wiring the Hardware

Connect each module to the ESP32-S3 using the pin assignments below. Work on a breadboard and double-check power rails before applying power — the microphone runs on 3.3 V while the amplifier needs 5 V.

INMP441 Microphone → I2S_NUM_1

ESP32-S3    INMP441
GPIO 42  -> SCK
GPIO 2   -> WS
GPIO 41  -> SD
3.3V     -> VDD
GND      -> GND

MAX98357A Amplifier → I2S_NUM_0

ESP32-S3    MAX98357A
GPIO 12  -> BCLK
GPIO 13  -> LRC
GPIO 14  -> DIN
5V       -> VIN
GND      -> GND

VL53L0X ToF Sensor → I2C (optional)

ESP32-S3    VL53L0X
GPIO 20  -> SDA
GPIO 21  -> SCL
3.3V     -> VIN
GND      -> GND

The repository includes a wiring diagram image (hardware/hw.png) that shows the full layout at a glance.

Configuration and Upload

1. Clone or download the repository from GitHub and open it in Arduino IDE.

2. Create your private config file. The repository ships a config_template.h. Copy it and rename the copy to config_private.h — this file is excluded from Git so your credentials stay local.

3. Fill in your credentials inside config_private.h:

#define WIFI_SSID     "YourWiFi"
#define WIFI_PASSWORD "YourPassword"
#define GCP_API_KEY   "your-api-key-here"
#define GEMINI_MODEL  "gemini-1.5-flash"

4. Open the sketch at assistente_ai_optimized/assistente_ai_optimized.ino.

5. Configure the board in Arduino IDE:

6. Upload. Once flashing completes, open the Serial Monitor. A blue LED signals a successful Wi-Fi connection. When you hear a beep, speak your question. The assistant will process the audio and reply through the speaker.

Tip: If you see config_private.h not found at compile time, you skipped step 2. If you get API error 403, verify the API key and confirm all three Google Cloud APIs are enabled on the same project.

How It Works Under the Hood

The firmware splits work across both cores of the ESP32-S3:

TLS sessions to Google's endpoints are kept open between requests rather than re-established each time, which is one of the main reasons the total latency dropped from roughly 54 seconds in v1 to around 20 seconds in the current release.

Long Gemini responses are automatically split at sentence boundaries before being passed to Text-to-Speech. This avoids buffer overflows and keeps playback sounding natural with correct pauses. A built-in retry system (up to two attempts per API call) and watchdog resets guard against transient network failures.

Tuning, Extensions and Limitations

Adjustable settings in the sketch let you change recording duration, chunk sizes and retry counts:

#define SAMPLE_RATE    16000   // Hz
#define RECORD_TIME    5       // seconds per recording
#define TTS_CHUNK_SIZE 800     // characters per TTS call
#define MAX_RETRIES    2       // API retry attempts

Enable the ToF sensor with #define ENABLE_TOF_SENSOR true for hands-free activation.

Ideas to extend the project:

Known limitations:

Verdict

ESP32-AI-Voice-Assistant is a well-structured, production-minded firmware that brings together three Google Cloud AI services on a single ESP32-S3 board with a clear wiring guide and a ready-to-edit config file. The dual-core architecture and persistent TLS connections deliver a meaningful speed improvement over a naive sequential approach, and the automatic error recovery makes it more reliable for everyday use than most hobby voice-assistant projects. The main trade-off is a hard dependency on Google Cloud APIs, so factor in ongoing API costs before committing it to a permanent installation.

Sources

github.comIngeimaks/ESP32-AI-Voice-Assistant — repository & README

Facts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.