DS-CNN keyword spotting for Algerian Darja smart-home commands on ESP32 (Heltec LoRa32 V2) — TensorFlow/Keras training, INT8 quantization, and TFLM/MicroTVM deployment.
# DS-CNN Keyword Spotting Pipeline
**Figure 1. TFLM deployment setup and serial monitor output during DS-CNN inference**
Welcome to the DS-CNN module for the **Keyword Spotting for Smart Home Control in Algerian Darja Using TinyML** project.
This folder implements the full pipeline for the DS-CNN model: training with TensorFlow/Keras, INT8 quantization, TFLite model export, and deployment on the ESP32 (Heltec WiFi LoRa 32 V2) using TensorFlow Lite for Microcontrollers (TFLM).
> **⭐ If you find this work useful, please consider giving it a star!**
## 📂 Project Structure
| Folder / File | Description |
|---|---|
| `train_ds_cnn.py` | Dataset loading, MFCC extraction, model training, INT8 export, and C-array generation |
| `export_model.py` | Generates MicroTVM AOT artifacts from the trained model |
| `TFLM-benchmark/` | PlatformIO firmware for running the model on-device using TFLM — **fully tested** |
| `MicroTVM-benchmark/` | PlatformIO firmware for running the model using Apache MicroTVM — provided for experimentation |
| `models/` | Output directory for trained model artifacts (`DS-CNN.h5`, `DS-CNN.tflite`, `DS-CNN.cc`) |
| `summary/` | Training output log and setup images |
## 🧠 Model Architecture
The V2 DS-CNN is a 2D depthwise separable CNN designed to fit within the ESP32 memory constraints, inspired by the Hello Edge baseline.
| Layer | Details |
|---|---|
| Input | (199, 13, 1) — MFCC features |
| Stem | Conv2D, 12 filters, BN, ReLU |
| DS Block 1 | Depthwise-separable, 12 filters, stride (2,1) |
| DS Block 2 | Depthwise-separable, 12 filters, stride (1,1) |
| DS Block 3 | Depthwise-separable, 16 filters, stride (2,1) |
| DS Block 4 | Depthwise-separable, 20 filters, stride (1,1) |
| Head | GlobalAveragePooling2D → Dropout(0.25) → Dense(17, softmax) |
## ⚙️ Training Configuration
| Parameter | Value |
|---|---|
| Dataset | 4,800 Algerian Darja commands + 300 noise files |
| Classes | 17 (16 commands + 1 noise) |
| Audio Input | 16 kHz mono, 2-se …