Example Code
tinySpeak ships with nine demo programs organized from simplest to most advanced. The first few require nothing but a tinyCore, tinySpeak, and an SD card. The later ones add WiFi and cloud AI APIs.
| Demo | Difficulty | SD Card | WiFi | API Key |
|---|---|---|---|---|
| tinyMP3Player | Beginner | Required | No | No |
| tinyRecorder | Beginner | Required | No | No |
| tinySoundboard | Beginner | Required | No | No |
| tinyTheremin | Beginner | No | No | No |
| tinyWalkieTalkie | Intermediate | No | No (ESP-NOW) | No |
| tinyWebSynth | Intermediate | Optional | Local only | No |
| tinyAIText | Advanced | Required | Yes | OpenAI |
| tinyAIVoice | Advanced | Required | Yes | OpenAI |
| tinyAIVoice_EL | Advanced | Required | Yes | OpenAI + ElevenLabs |
tinyMP3Player
Section titled “tinyMP3Player”A straightforward SD card music player. Drop .mp3 files into the root of your SD card and tinyMP3Player will find and play them in order, automatically advancing to the next track when each one finishes.
Control playback from the Serial Monitor with single-key commands for play/pause, next/previous track, and volume. If the optional RX button is installed, a single press toggles play/pause and a quick double-press skips to the next track.
Serial Monitor Controls
| Key | Action |
|---|---|
p | Play / Pause |
n | Next track |
b | Previous track |
+ / - | Volume up / down |
? | Show menu |
tinyRecorder
Section titled “tinyRecorder”A standalone voice recorder that captures audio from the MEMS microphone and saves it as a standard 16-bit 16kHz WAV file on the SD card. Hold the RX button to record and release to stop — the recording is saved to /recording.wav and can be played back immediately by pressing p.
WAV files are standard PCM format, so you can pull the SD card and open them on any computer.
Serial Monitor Controls
| Key | Action |
|---|---|
r | Toggle recording |
p | Play back last recording |
s | Stop playback |
? | Show menu |
tinySoundboard
Section titled “tinySoundboard”A motion-triggered soundboard that plays sound effects when you shake the board. It reads the tinyCore’s built-in LSM6DSO IMU to detect a shake gesture — when acceleration exceeds a configurable threshold, it fires off the current sound effect from the SD card.
Load .mp3 or .wav files into the root of your SD card and tinySoundboard picks them up automatically. You can also trigger sounds with the RX button or cycle through files from the Serial Monitor.
tinyTheremin
Section titled “tinyTheremin”A motion-controlled musical instrument. Tilt the board left and right to change pitch (200–1000 Hz) and tilt forward and back to change volume. Audio is generated in real time as a pure sine wave, synthesized sample-by-sample and pushed directly to the speaker over I2S — no audio files involved.
The demo auto-calibrates on boot (hold the board flat and still during startup). Recalibrate anytime by pressing c. The RX button acts as a mute toggle.
This is the only demo that drives I2S directly using the ESP-IDF driver rather than the Audio library — a useful reference if you want to understand raw I2S audio synthesis on the ESP32-S3.
tinyWalkieTalkie
Section titled “tinyWalkieTalkie”A push-to-talk intercom that streams live audio between two or more tinySpeak units using ESP-NOW — Espressif’s low-latency peer-to-peer protocol. No WiFi router, no internet connection, no server required.
Audio is captured from the microphone at 8kHz, packed into 240-byte ESP-NOW frames, and broadcast to all nearby tinySpeak devices on the same channel. Incoming packets are written directly into the speaker’s I2S DMA buffer for immediate playback. Hold RX to transmit, release to listen.
Press c in the Serial Monitor to cycle through WiFi channels 1–11. All units must be on the same channel to hear each other.
tinyWebSynth
Section titled “tinyWebSynth”A chiptune synthesizer with a browser-based UI. The ESP32 runs a local web server and WebSocket endpoint. Connect to its IP address from any device on the same WiFi network and you get a full musical interface: a live piano keyboard, a two-track melodic step sequencer, and a three-track drum machine with kick, snare, and hi-hat. All audio is generated on the ESP32 — the browser is purely a controller.
The audio engine runs five simultaneous channels with selectable waveforms (square, sawtooth, pulse), per-channel envelope control, and configurable BPM. Export your composition as a WAV file to the SD card from the Serial Monitor. Songs are saved in the browser’s localStorage between sessions.
On first boot the demo will prompt you for your WiFi credentials through the Serial Monitor.
tinyAIText
Section titled “tinyAIText”A text-based AI assistant. Type a question into the Serial Monitor, and the ESP32 sends it to OpenAI’s ChatGPT API (GPT-4o-mini), converts the text response to speech using OpenAI TTS, saves the MP3 to the SD card, and plays it through the speaker. Text in, voice out — no browser or companion app needed.
This is the simplest of the three AI demos because it skips the microphone entirely. It’s a good starting point for understanding the OpenAI API integration before adding voice input.
On first boot, a configuration wizard will walk you through entering your WiFi SSID, password, and OpenAI API key. These are saved to flash and persist across reboots. Press c at any time to reconfigure.
Serial Monitor Controls
| Key | Action |
|---|---|
| Type a message + Enter | Send to ChatGPT and speak the reply |
s | Stop speaking |
c | Configure WiFi / OpenAI key |
? | Show menu |
tinyAIVoice
Section titled “tinyAIVoice”A full voice-in, voice-out AI assistant. Hold the RX button and speak your question, release the button, and the device runs a three-stage pipeline: your speech is transcribed by OpenAI Whisper (speech-to-text), the transcript is sent to ChatGPT for a response, and the reply is spoken aloud using OpenAI TTS. The entire round trip typically completes in a few seconds.
Audio is recorded to the SD card as a WAV file before being uploaded to Whisper, and the TTS response is streamed directly to SD as an MP3 before playback. This avoids buffering large audio payloads in the ESP32’s limited RAM.
If you don’t have the RX button installed, toggle recording with the r command in the Serial Monitor.
Serial Monitor Controls
| Key | Action |
|---|---|
| Hold RX button | Start recording |
| Release RX button | Stop recording and process |
r | Toggle recording via Serial |
s | Stop speaking |
c | Configure WiFi / OpenAI key |
? | Show menu |
tinyAIVoice (ElevenLabs)
Section titled “tinyAIVoice (ElevenLabs)”A premium voice assistant that replaces OpenAI’s TTS engine with ElevenLabs for higher-quality, more natural-sounding speech synthesis. The pipeline is otherwise identical to tinyAIVoice: hold the button to record, release to process through Whisper (speech-to-text), ChatGPT (intelligence), and ElevenLabs (text-to-speech).
ElevenLabs offers a wide variety of voice options and supports voice cloning. The demo defaults to the “Arthur” voice, but you can change the voice ID through the configuration wizard. To find voice IDs, browse the ElevenLabs voice library and copy the ID from your chosen voice’s page.
The configuration wizard asks for five values: WiFi SSID, WiFi password, OpenAI API key (for Whisper and ChatGPT), ElevenLabs API key, and ElevenLabs voice ID.
Serial Monitor Controls
| Key | Action |
|---|---|
| Hold RX button | Start recording |
| Release RX button | Stop recording and process |
r | Toggle recording via Serial |
s | Stop speaking |
c | Configure WiFi / API keys / Voice ID |
? | Show menu |
WiFi & API Key Configuration
Section titled “WiFi & API Key Configuration”The AI demos (tinyAIText, tinyAIVoice, tinyAIVoice_EL) and tinyWebSynth share a configuration system built on the ESP32’s Preferences library. Credentials are stored in onboard flash and persist across power cycles and reflashes — you only enter them once.
On first boot, if no configuration is found, the demo automatically launches an interactive setup wizard in the Serial Monitor. It prompts for each required field one at a time. Passwords and API keys are masked with asterisks as you type.
To reconfigure, press c in the Serial Monitor at any time. The wizard shows your current values (keys partially redacted) and lets you press Enter to keep any field unchanged, or type a new value to update it.
Getting an OpenAI API Key
Section titled “Getting an OpenAI API Key”Go to platform.openai.com/api-keys, sign in or create an account, and generate a new secret key. You will need to add a payment method, but usage costs for these demos are very low — a typical conversation costs fractions of a cent.
Getting an ElevenLabs API Key
Section titled “Getting an ElevenLabs API Key”Go to elevenlabs.io, create an account, and find your API key in your profile settings. ElevenLabs offers a free tier with a limited number of characters per month, which is more than enough for experimenting with tinyAIVoice_EL.
Serial Monitor
Section titled “Serial Monitor”Connect to your tinyCore to view debug output, send commands, and interact with the demo programs. Make sure your tinyCore is plugged in via USB-C and you’ve selected the correct port.