SpeechCommandsDataLoader<T>
Models & Types · AiDotNet.Data.Audio.Benchmarks
Loads the Google Speech Commands v2 dataset (~65K clips, 35 words, 16kHz).
Inheritance: DataLoaderBase<T> → InputOutputDataLoaderBase<T, Tensor<T>, Tensor<T>> → SpeechCommandsDataLoader<T>
How It Works
Speech Commands v2 expects the following directory structure after extraction:
Each subdirectory is a word class. WAV files are 16-bit PCM mono at 16kHz, ~1 second each.
Streaming behaviour: the loader does NOT preload audio waveforms into memory.
File paths and class indices are scanned eagerly during LoadAsync, but the
actual WAV decoding (and resampling, if configured) happens per-batch in
ExtractBatch. This is intentional: the full 35-class dataset would
allocate ~4 GB of float32 features in memory, so eager loading was guaranteed to OOM.
Use GetBatches / GetBatchesAsync for training; direct
Features access on this loader is intentionally not supported (features
are decoded lazily per batch). Labels is a small [N, numClasses]
one-hot tensor and is materialized during LoadAsync, so it remains available.
Class scheme: the “core” 12-class subset (default) follows Warden 2018:
the 10 keyword classes (yes, no, up, down, left, right, on, off, stop, go) plus
_silence_ (sampled from _background_noise_/) and _unknown_
(collapses every non-core word directory). The full 35-class mode uses all word
directories with no synthetic classes.
Auto-download: when AutoDownload
is true (default), the loader fetches and extracts the tarball from
DownloadUrl if the data directory is empty, mirroring
LibriSpeechDataLoader.
Constructors
| Constructor | Summary |
|---|---|
SpeechCommandsDataLoader(SpeechCommandsDataLoaderOptions options) |
Creates a new Speech Commands data loader. |
Properties
| Property | Summary |
|---|---|
IReadOnlyList<string> AllWords { get; } |
All 35 word classes in the full dataset. |
IReadOnlyList<string> CoreWords { get; } |
Core 10 spoken words (the standard benchmark subset). |
IReadOnlyList<string> WordList { get; } |
Gets the word list being used (10/35 word names plus the two synthetic labels in core mode). |
int FeatureCount { get; } |
|
int NumClasses { get; } |
Number of word classes (12 in core mode, 35 in full mode). |
int OutputDimension { get; } |
|
int TotalCount { get; } |
|
string Description { get; } |
|
string Name { get; } |
Methods
| Method | Summary |
|---|---|
ValueTuple<IInputOutputDataLoader<T, Tensor<T>, Tensor<T>>, IInputOutputDataLoader<T, Tensor<T>, Tensor<T>>, IInputOutputDataLoader<T, Tensor<T>, Tensor<T>>> Split(double trainRatio, double validationRatio, int? seed) |
Fields
| Field | Summary |
|---|---|
string BackgroundNoiseDir |
Subdirectory containing the long background-noise WAVs distributed with the dataset. |
string DownloadUrl |
HTTPS URL of the Speech Commands v2 archive. |
string SilenceLabel |
Synthetic class label for background-noise / silence in the 12-class subset. |
string UnknownLabel |
Synthetic class label for non-keyword speech in the 12-class subset. |