Arduino library for extracting 28 audio features from I2S microphones (such as IMP441, INMP441) on ESP32.
This library extracts 28 features from audio signals:
| # | Feature | Description |
|---|---|---|
| 0 | Peak Frequency | Main peak frequency in the spectrum (Hz) |
| 1 | Spectral Centroid | Spectral center of mass (Hz) |
| 2-14 | MFCC 1-13 (Mean) | Mean values of 13 MFCC coefficients |
| 15-27 | MFCC 1-13 (Std) | Standard deviation of 13 MFCC coefficients |
- 🤖 Machine Learning / AI for audio recognition
- 🔊 Audio classification (sounds, voice, music)
- 🎤 Keyword spotting
- 📊 Audio feature analysis
- Open Arduino IDE
- Go to Sketch > Include Library > Manage Libraries
- Search for "ESP32Feature28"
- Click Install
- Download this library
- Extract to
Arduino/libraries/folder - Restart Arduino IDE
Required library:
- arduinoFFT (by Enrique Condes) - Version 2.0.0 or higher
#include <ESP32Feature28.h>
Feature28Extractor extractor(16000); // 16kHz sample rate
void setup() {
Serial.begin(115200);
// Initialize I2S (see example)
setupI2S();
// Reset extractor
extractor.reset();
// Feed audio (example: 2 seconds)
for (uint32_t i = 0; i < totalSamples; i += chunkSize) {
size_t bytesRead;
i2s_read(I2S_NUM_0, audioBuffer, bufferSize, &bytesRead, portMAX_DELAY);
extractor.feed(audioBuffer, bytesRead / 2);
}
// Compute 28 features
float features[28];
if (extractor.compute(features)) {
Serial.printf("Peak Frequency: %.2f Hz\n", features[0]);
Serial.printf("Spectral Centroid: %.2f Hz\n", features[1]);
for (int i = 0; i < 13; i++) {
Serial.printf("MFCC%d mean: %.6f\n", i+1, features[2+i]);
}
for (int i = 0; i < 13; i++) {
Serial.printf("MFCC%d std: %.6f\n", i+1, features[15+i]);
}
}
}
void loop() {
// Your code here
}| IMP441 | ESP32-S3 |
|---|---|
| SCK | GPIO 12 |
| WS | GPIO 11 |
| SD | GPIO 10 |
| VDD | 3.3V |
| GND | GND |
Note: GPIO pins can be changed in code
Feature28Extractor(uint32_t sampleRate = 16000)Initialize extractor with sampling rate (Hz)
void reset()
- Reset all buffers and accumulators
- Call before processing a new audio segment
void feed(const int16_t* samples, size_t n)
- Feed PCM16 mono data into extractor
samples: Array of 16-bit signed integer samplesn: Number of samples
bool compute(float out28[28])
- Compute 28 features
out28: Output array to store results- Return:
trueif successful,falseif insufficient data
uint32_t fftBlocksProcessed()
- Returns number of FFT blocks processed
uint32_t mfccFramesProcessed()
- Returns number of MFCC frames processed
You can customize parameters by defining them before including the library:
#define F28_SAMPLE_RATE 16000 // Sample rate
#define F28_FMIN_HZ 100.0f // Minimum frequency of interest
#define F28_FMAX_HZ 1000.0f // Maximum frequency of interest
#define F28_MFCC_COEFFS 13 // Number of MFCC coefficients
#include <ESP32Feature28.h>See Feature28Extractor.h for all available parameters.
Complete example of reading audio from IMP441 and extracting 28 features.
See examples/IMP441_BasicExample/ folder
All contributions are welcome! Please:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
BY-NC 4.0 - See LICENSE file for details
Your Name
- Email: huuphuoc.research@gmail.com
- GitHub: Huu-Phuoc Nguyen
This project is developed for scientific research and educational purposes only and is not intended for commercial use.
If you use ESP32Feature28 in any academic work, including but not limited to journal articles, conference papers, theses, or technical reports, you MUST cite the software using the following reference.
Phuoc, H. (2025). ESP32Feature28: Audio feature extraction library for ESP32
(Version 1.0.0) [Software]. Zenodo.
https://doi.org/10.5281/zenodo.18122898
@software{phuoc_esp32feature28_2025,
author = {Huu Phuoc},
title = {ESP32Feature28: Audio feature extraction library for ESP32},
version = {1.0.0},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.18122898},
url = {https://doi.org/10.5281/zenodo.18122898}
}
- arduinoFFT library by Enrique Condes
- Arduino and ESP32 community
Q: Why do I need to feed at least 2 seconds of audio?
A: To accurately calculate MFCC mean/std, multiple frames are needed. 2 seconds @ 16kHz = ~125 MFCC frames.
Q: Does it support microphones other than IMP441?
A: Yes, any I2S microphone that outputs PCM16 mono is supported (INMP441, SPH0645, etc.)
Q: How much RAM does it use?
A: Approximately ~30KB for buffers and mel filterbank. Suitable for ESP32.
Q: Processing speed?
A: Real-time on ESP32 @ 240MHz. Processing time << recording time.
- ✨ Initial release
- 🎯 28 features: Peak, Centroid, MFCC mean/std
- 📦 Support ESP32 + I2S microphones
- 📚 Full documentation and examples