Real-time audio analysis platform using ESP32, FastAPI, and React. The system captures audio data from a microphone connected to ESP32, processes the signal in real-time, and displays detailed analysis in a modern web dashboard.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ESP32 Device β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Microphone β ADC β FFT Analysis β WebSocket β β
β β - Sample Rate: 16kHz β β
β β - FFT Samples: 128 β β
β β - Frequency Bands: 9 (0-8kHz) β β
β β - Real-time filtering & SNR calculation β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β WebSocket (WSS)
β Port 443
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend Server β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β WebSocket Manager β β
β β - /ws (ESP32 endpoint) β β
β β - /ws-dashboard (Frontend endpoint) β β
β β - Real-time data broadcasting β β
β β - Connection management β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β REST API β β
β β - /api/info (System information) β β
β β - CORS enabled β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β WebSocket (WSS)
β HTTP/HTTPS
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Real-Time Dashboard β β
β β - Waveform Charts (RAW & FILTERED) β β
β β - Spectrogram Visualization β β
β β - Frequency Bands Display β β
β β - Signal Quality Metrics (SNR) β β
β β - Filter Controls (Low/High/Band-Pass) β β
β β - Measurement Log β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Hardware Setup: ESP32 + Pre-Amplifier + Electret Microphone
- Features:
- Audio capture at 16kHz
- FFT analysis with 9 frequency bands
- Real-time filtering (Low-Pass, High-Pass, Band-Pass)
- Signal quality metrics: SNR, MSE, and PSNR calculations
- Noise gate and automatic calibration
- WebSocket communication with backend
- Framework: FastAPI (Python)
- Features:
- WebSocket server for ESP32 and Dashboard
- Real-time broadcast to all dashboards
- Connection management
- REST API for system information
- Structured logging
http://localhost:8000/docs- Framework: React + TypeScript + Vite
- UI: Tailwind CSS
- Features:
- Real-time visualizations (waveform, spectrogram)
- Audio filter controls (cutoff frequencies, voice boost)
- Signal quality metrics (SNR, MSE, PSNR)
- Measurement log
- Connection status (Dashboard & ESP32)
- Docker
- Docker Compose
# Clone the repository
git clone <repository-url>
cd psad-project
# Run all services
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f- Frontend: http://localhost:3000
- Backend API: http://localhost:8000/api
- Backend Health: http://localhost:8000/api/health
- Backend WebSocket: ws://localhost:8000/ws (ESP32)
- Dashboard WebSocket: ws://localhost:8000/ws-dashboard
docker-compose downcd server
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 8000 --reloadcd client
npm install
npm run dev- Open
arduino/microphone_websocket.inoin Arduino IDE - Install required libraries:
WiFi(built-in)WebSocketsClient(from Links2004)
- Configure WiFi credentials in code
- Configure WebSocket host/port
- Upload to ESP32
volume: RAW amplitude (0-100%)volumeFiltered: Filtered amplitude (0-100%)peakToPeak: Peak-to-peak (ADC units)bands: Array with 9 FFT bands (RAW)bandsFiltered: Array with 9 FFT bands (FILTERED)snrRaw: Signal-to-Noise Ratio RAW (dB)snrFiltered: Signal-to-Noise Ratio FILTERED (dB)mse: Mean Squared Error between RAW and FILTERED bands (lower is better)psnr: Peak Signal-to-Noise Ratio (dB, higher is better)min,max,avg: ADC values
- SNR (Signal-to-Noise Ratio): Measures signal quality by comparing signal energy to noise floor
- RAW SNR: Quality of unfiltered signal
- FILTERED SNR: Quality after filtering
- MSE (Mean Squared Error): Average squared difference between RAW and FILTERED frequency bands
- Lower values indicate better preservation of original signal characteristics
- PSNR (Peak Signal-to-Noise Ratio): Logarithmic measure of signal quality
- Higher values (typically >30 dB) indicate better signal quality
- Formula: PSNR = 20 Γ logββ(MAX_VALUE / βMSE)
- Low-Pass: Removes frequencies above cutoff
- High-Pass: Removes frequencies below cutoff
- Band-Pass: Keeps frequencies between 2 cutoffs
- Voice Boost: Amplification for vocal bands (500Hz-2500Hz)
- ESP32: WiFi-enabled microcontroller
- FastAPI: Modern Python backend
- React + TypeScript: Reactive frontend
- WebSocket: Bidirectional real-time communication
- Tailwind CSS: Modern styling
- Vite: Fast build tool for frontend
- Docker: Containerization and deployment
psad-project/
βββ arduino/ # ESP32 Firmware
β βββ microphone_websocket.ino
βββ server/ # FastAPI Backend
β βββ app.py
β βββ routes/ # API & WebSocket routes
β βββ services/ # Business logic
β βββ config/ # Configuration
β βββ requirements.txt
βββ client/ # React Frontend
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom hooks
β β βββ services/ # API utilities
β βββ package.json
βββ docker-compose.yml # Docker orchestration
βββ Dockerfile.backend # Backend container
βββ Dockerfile.frontend # Frontend container
βββ README.md
No environment variables required (configured in code)
Create .env in client/:
VITE_API_URL_FASTAPI=wss://your-backend-url.com- Sample Rate: 16kHz
- FFT Resolution: 128 samples (~125Hz per bin)
- Update Rate: 350ms (configurable)
- Frequency Range: 0-8kHz
- Bands: 9 bands optimized for human voice
- Check WiFi credentials
- Check WebSocket host/port
- Verify backend is running
- Check WebSocket connection in browser console
- Verify ESP32 is sending data
- Check CORS settings in backend
- Verify ports 3000 and 8000 are available
- Check logs:
docker-compose logs
See LICENSE for details.



