A TensorLab-compatible 12-class variant of the Google Speech Commands dataset for keyword spotting and audio classification experiments using TinyML models such as DSCNN. ---
Downloaded automatically via TorchAudio:
torchaudio.datasets.SPEECHCOMMANDS(
root=root,
url="speech_commands_v0.02",
folder_in_archive="SpeechCommands",
download=True,
) ┌────────────────┬──────────────────────────────────────────────────────────┐
│ Type │ Labels │
├────────────────┼──────────────────────────────────────────────────────────┤
│ Known keywords │ down, go, left, no, off, on, right, stop, up, yes │
├────────────────┼──────────────────────────────────────────────────────────┤
│ Unknown │ _unknown_ - all non-keyword words (e.g. bird, cat, tree) │
├────────────────┼──────────────────────────────────────────────────────────┤
│ Silence │ _silence_ - 1-second clips from _background_noise_/ │
└────────────────┴──────────────────────────────────────────────────────────┘
- Install dependencies
python -m pip install torch torchaudio scipy pydub numpy tqdm- Generate the dataset
python generate_dataset.py SpeechCommands/
├── speech_commands_v0.02/ # Original downloaded dataset
│ ├── down/
│ ├── go/
│ └── _background_noise_/
└── classes/ # TensorLab-ready dataset
├── down/
├── go/
├── left/
├── no/
├── off/
├── on/
├── right/
├── stop/
├── up/
├── yes/
├── _silence_/
└── _unknown_/
What generate_dataset.py Does:
- Downloads Google Speech Commands v0.02 via TorchAudio
- Copies the 10 keyword classes into their own folders
- Maps all other word classes into unknown (prefixing the original label to avoid filename collisions)
- Splits background_noise/ audio into 1-second clips for silence
- Saves everything under SpeechCommands/classes/
Silence samples are not recorded speech - they are synthetic clips cut from the background noise audio files in_background_noise_/.
Source files: all .wav files inside SpeechCommands/speech_commands_v0.02/_background_noise_/
Process (create_silence_samples):
- Each background noise file is loaded in full via
pydub.AudioSegment - Raw PCM samples are extracted as a NumPy array
- The array is sliced into 1-second windows using a sliding loop with 50% overlap.
- Each segment is written to classes/silence/ as a 16-bit .wav file
GoogleSpeechCommands_MFCC_Default = dict(
data_processing_feature_extraction=dict(
sampling_rate=16000,
audio_duration_ms=1000,
audio_feature="MFCC",
n_mfcc=10,
n_mels=40,
frame_length_ms=30,
frame_step_ms=20,
normalize_audio=True,
mono=True,
variables=1,
feat_ext_transform=["MFCC"],
data_proc_transforms=[],
),
common=dict(
task_type=TASK_TYPE_AUDIO_CLASSIFICATION,
),
)
MFCCs (Mel Frequency Cepstral Coefficients) compactly represent the frequency characteristics of speech, making them well-suited for keyword spotting.
┌───────────────────┬──────────┐
│ Parameter │ Value │
├───────────────────┼──────────┤
│ Sampling rate │ 16000 Hz │
├───────────────────┼──────────┤
│ Audio duration │ 1000 ms │
├───────────────────┼──────────┤
│ Frame length │ 30 ms │
├───────────────────┼──────────┤
│ Frame step │ 20 ms │
├───────────────────┼──────────┤
│ MFCC coefficients │ 10 │
├───────────────────┼──────────┤
│ Mel bins │ 40 │
└───────────────────┴──────────┘
Output feature shape: [N, 1, 49, 10] (batch size × 1 channel × 49 time frames × 10 MFCC coefficients)
The recommended model is DSCNN (Depthwise Separable Convolutional Neural Network), designed for efficient TinyML inference on our NPU
Architecture
Conv10x4 / stride 2 Dropout Depthwise3x3 + Pointwise1x1 ×4 Dropout AdaptiveAvgPool Fully Connected (→ 12 classes)
Filters: 64 | Output classes: 12
A standard convolution performs spatial filtering and channel mixing in one operation. DSCNN splits this into:
- Depthwise conv - spatial filtering independently per channel
- Pointwise conv - 1×1 convolution for channel mixing
This reduces computation and model size while maintaining strong keyword spotting accuracy, making it suitable for embedded deployment.