Stream audio from an INMP441 I2S microphone over Wi-Fi using an ESP8266, then receive and transcribe it on your PC in real-time using Python.
happy to help at any time (i do not respond fast i have school)
- UDP Audio Streaming β Low-latency audio packets sent from ESP8266 to PC over your local network
- Arduino OTA (Over-The-Air) Updates β Flash new firmware to the ESP8266 wirelessly; no USB cable needed after first flash
- 160 MHz CPU Overclock β The ESP8266 is set to run at 160 MHz (
system_update_cpu_freq(160)) for smooth, uninterrupted audio capture and transmission - Software Gain Boosting β Python-side gain amplifier (
GAIN_FACTOR) compensates for the INMP441's quiet output; clipping is prevented automatically - Speech-to-Text via Google β Received audio is automatically transcribed using Google's Speech Recognition API
- Mono 16-bit PCM, 16 kHz β Clean audio format compatible with most speech recognition engines
esp/
βββ esp8266_mic/
β βββ esp8266_mic.ino # ESP8266 firmware (I2S capture + UDP send + OTA)
βββ python_receiver/
β βββ main.py # PC-side receiver (UDP listen + gain boost + transcribe)
β βββ requirements.txt # Python dependencies
βββ README.md
| Component | Details |
|---|---|
| ESP8266 | NodeMCU / Wemos D1 Mini |
| Microphone | INMP441 (I2S digital mic) |
| INMP441 Pin | ESP8266 Pin |
|---|---|
| VDD | 3.3V |
| GND | GND |
| WS (LRCK) | GPIO14 (D5) |
| SCK (BCLK) | GPIO13 (D7) |
| SD (Data) | GPIO12 (D6) |
| L/R | GND (for left channel) |
- Open Arduino IDE β File β Preferences
- Paste this URL into Additional Boards Manager URLs:
http://arduino.esp8266.com/stable/package_esp8266com_index.json - Go to Tools β Board β Boards Manager, search
esp8266, and install it
In Arduino IDE go to Sketch β Include Library β Manage Libraries and install:
ArduinoOTA(usually bundled with the ESP8266 core)I2S(bundled with ESP8266 core β do not use the Arduino built-in I2S)
β οΈ CRITICAL β the 160 MHz setting is required for stable audio streaming.
Go to Tools and set the following:
| Setting | Value |
|---|---|
| Board | NodeMCU 1.0 (ESP-12E Module) (or your board) |
| CPU Frequency | 160 MHz β must be 160 MHz |
| Upload Speed | 921600 |
| Flash Size | 4MB (FS:2MB OTA:~1019KB) |
Open esp8266_mic/esp8266_mic.ino and update these lines:
const char* STASSID = "your-ap"; // β Your Wi-Fi network name (SSID)
const char* STAPSK = "your_password"; // β Your Wi-Fi password
const IPAddress listener(192, 168, 1, XX); // β Your PC's local IP address
const int port = 3333; // β UDP port (keep default or change both sides)π‘ Find your PC's local IP by running
ipconfig(Windows) orip a(Linux) in a terminal.
- Connect your ESP8266 via USB
- Select the correct Port under Tools β Port
- Click Upload (β)
- Open Serial Monitor at 115200 baud β you should see
Streaming Started...
Once the ESP8266 is connected to Wi-Fi:
- Under Tools β Port, a network port called
esp8266-micwill appear - Select it and click Upload as usual β no USB needed!
Make sure Python 3.8+ is installed:
python --versionβ Always use a virtual environment to avoid dependency conflicts.
# Navigate to the python_receiver folder
cd esp/python_receiver
# Create the virtual environment
python -m venv venv
# Activate it
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txtOpen python_receiver/main.py and check/update these values:
UDP_IP = "0.0.0.0" # Listen on all interfaces (keep this)
UDP_PORT = 3333 # Must match the port set in the .ino file
SAMPLE_RATE = 16000 # Must match i2s_set_rate() in the .ino (16000)
GAIN_FACTOR = 5.0 # Increase if audio is too quiet (try 3.0β10.0)When you first run the script, Windows Firewall may prompt you β click "Allow" to permit UDP traffic on port 3333.
python main.pyYou should see:
Listening with 5.0x gain on port 3333...
Speak near the INMP441 β transcribed text will print to the console every ~5 seconds.
###part2.2 ffplay
ffplay -fflags nobuffer -flags low_delay -probesize 32 -analyzeduration 0 -sync ext -nodisp -af "volume=5.0" -f s16le -sample_rate 16000 -ch_layout mono -i "udp://0.0.0.0:3333?fifo_size=0&overrun_nonfatal=1"| Problem | Fix |
|---|---|
| Audio is too quiet | Increase GAIN_FACTOR in main.py (e.g. 8.0) |
| Audio is distorted / clipping | Decrease GAIN_FACTOR (e.g. 3.0) |
| Packets dropping / stream stutters | Ensure ESP8266 CPU is set to 160 MHz in Arduino IDE |
| OTA port not showing | Make sure ESP8266 is on the same Wi-Fi network as your PC; restart Arduino IDE |
| Transcription fails | Check your internet connection (Google Speech API requires internet) |
See python_receiver/requirements.txt.
| Package | Purpose |
|---|---|
sounddevice |
Audio device interface |
numpy |
Gain boost math (fast array operations) |
SpeechRecognition |
Google Speech-to-Text interface |
PyAudio |
Audio I/O backend required by SpeechRecognition |
cffi |
C Foreign Function Interface (sounddevice dependency) |
- The 160 MHz CPU frequency is set in firmware via
system_update_cpu_freq(160)insetup(). You must also set it in Arduino IDE under Tools β CPU Frequency before uploading, or the setting may be overridden by the bootloader. - Audio is captured as 16-bit signed integers, mono, 16 kHz β the left I2S channel only (the INMP441's L/R pin is tied to GND).
- The Python script buffers ~5 seconds of audio before transcribing to give the Google API enough context for accurate results.
- OTA hostname is
esp8266-micβ you can ping it atesp8266-mic.localif mDNS is working on your network.
MIT β free to use, modify, and distribute.