kws-dataset / README.md
Simonlob's picture
Upload README.md
ef9e9b8 verified
|
Raw
History Blame Contribute Delete
21 kB
metadata
license: apache-2.0
language:
  - ky
  - ru
task_categories:
  - tabular-classification
  - audio-classification
tags:
  - keyword-spotting
  - wake-word
  - kyrgyz
  - speech
  - mfcc
  - spectral-features
  - educational
  - teaching
size_categories:
  - 10K<n<100K
pretty_name: Akylai KWS Features  Educational Spectral-Feature Dataset

Akylai KWS Features — An Educational Spectral-Feature Dataset for Keyword Spotting

A ready-to-model, tabular dataset for teaching binary classification on a real speech problem: detecting the Kyrgyz wake word «Акылай» (Akylai) versus everything else. Each row is one short audio clip already converted into a fixed-length vector of 250 spectral features, so students can go straight to scikit-learn without touching a single audio library — yet the problem is a genuine, non-toy Keyword Spotting (KWS) task with a natural class imbalance, several distinct negative sub-populations, and instructive failure modes.

One-line summary. 40 000 clips → 250 acoustic features → binary label (1 = wake word, 0 = not). Mildly imbalanced (1 : 3). Built for an ML course that has just covered linear models (Logistic Regression, SVM) and is about to meet trees.


Table of contents

  1. The task: what is Keyword Spotting?
  2. A short history of wake words
  3. Where the audio comes from (provenance)
  4. From a waveform to a feature vector
  5. The features, in detail (with formulas)
  6. Temporal aggregation: variable-length audio → fixed vector
  7. Dataset schema
  8. Modeling challenges (read this before you trust your accuracy)
  9. License, provenance & citation

1. The task: what is Keyword Spotting?

Keyword Spotting (KWS) is the problem of detecting a small set of predefined words or short phrases in an audio stream. The most familiar special case is wake-word detection (also hotword or trigger-word detection): a tiny, always-listening model that waits for a single phrase — "Hey Siri", "OK Google", "Alexa" — and only then wakes up the heavy, cloud-based speech recogniser.

Formally, given an audio segment $x(t)$ we want a decision function

y^=1 ⁣[p(keywordx)τ], \hat{y} = \mathbb{1}\!\left[\, p(\text{keyword} \mid x) \ge \tau \,\right],

where $\tau$ is an operating threshold. In this dataset the keyword is the Kyrgyz given name «Акылай» (three syllables, stress on the final -ай), and the task is reduced to its cleanest form: binary classification of pre-segmented 2-second-scale clips — keyword vs. non-keyword.

KWS has several properties that make it a richer teaching example than tabular toy datasets:

  • Strong class imbalance. In deployment the keyword is vanishingly rare (a wake word may fire a handful of times per day against hours of non-keyword audio). Here we use a gentle 1 : 3 ratio — enough to make accuracy misleading without being degenerate.
  • Asymmetric error costs. A false reject (missing the keyword) annoys the user once; a false accept (waking up on a TV advert) is far worse. This motivates the whole precision/recall/threshold toolkit rather than a single accuracy number.
  • A meaningful feature-engineering step. Audio is not naturally tabular. Turning a waveform into a fixed-length vector is itself a modelling decision — and a great lesson.

2. A short history of wake words

  • 1950s–60s — first isolated-word recognisers. Bell Labs' Audrey (1952) recognised spoken digits from a single speaker; IBM's Shoebox (1962) handled 16 words. These were analog/template machines, but they established the core idea of matching short acoustic patterns.
  • 1970s–80s — features and dynamic time warping. The cepstrum and then Mel-Frequency Cepstral Coefficients (MFCCs) (Davis & Mermelstein, 1980) became the standard front-end, and DTW allowed matching words of different durations.
  • 1980s–2000s — statistical models. Hidden Markov Models (HMMs) with Gaussian Mixture emissions dominated speech. Classic KWS was often keyword-filler HMMs: one model for the keyword, a "garbage" model for everything else.
  • 2014 — the deep-learning turning point for KWS. Google's "Small-footprint keyword spotting using deep neural networks" (Chen, Parada & Heigold, 2014) showed a compact DNN on log-mel features beating the HMM pipeline — the recipe behind "OK Google" on-device.
  • 2014–2017 — the smart-speaker era. Amazon Echo / Alexa (2014), "Hey Siri" on a dedicated low-power core (2017), and "OK Google" turned always-on wake-word detection into a mass-market component. Constraints became extreme: a few tens of kilobytes of parameters, running continuously at milliwatts.
  • 2018–present — convolutional & streaming models. Architectures such as TC-ResNet, BC-ResNet, and depthwise-separable CNNs pushed accuracy up while keeping the model tiny enough for an MCU/NPU.

This dataset's parent project trains exactly such a tiny on-device model (a ~30 K-parameter BC-ResNet) for «Акылай». The features you have here are the classical front-end — MFCCs and spectral descriptors — which is both historically faithful and a perfect bridge from "linear models on tables" to "real speech".


3. Where the audio comes from (provenance)

The clips come from four different sources, recorded in the source column. The single most important thing to understand about this dataset is the split between synthetic (text-to-speech, TTS) audio and real human audio.

source label n Synthetic / real What it is
positive 1 10 000 TTS (in-house Kyrgyz TTS) The wake word «Акылай», spoken by a Kyrgyz text-to-speech model trained on podcast voices.
base_neg 0 7 680 TTS (same engine as positives) Other Kyrgyz words/phrases from the same TTS voice — not the wake word.
confusable 0 2 949 TTS (KaniTTS, a different engine) Phonetic near-neighbours — words ending in -ай / -лай / -кай / -бай (e.g. Алтынай, калай, чай, лайк) designed to look "almost" like the keyword.
podcast 0 19 371 Real human speech 2-second cuts of continuous Kyrgyz podcast speech — natural, spontaneous, with no wake word.

Why this matters (and why we keep source). The negatives are not homogeneous:

  • podcast is real, out-of-domain audio → in practice it is easy to separate from the synthetic positives, partly for the wrong reason (the model can latch onto "synthetic vs. real" timbre rather than the word itself — a classic shortcut).
  • base_neg shares the exact same TTS voice as the positives, so the only thing distinguishing it from a positive is the word → this is the honest, hard part of the problem.
  • confusable tests robustness to phonetically similar words.

The source column is not a feature — never feed it to the model. It is provided for error analysis: which kind of negative does your model actually fail on? (Spoiler from our baseline experiments: almost all false positives come from base_neg.)

Wake word. «Акылай» — a Kyrgyz feminine given name, 3 syllables, stress on -ай. All audio is 16 kHz mono.


4. From a waveform to a feature vector

A raw clip is a sequence of $16,000$ amplitude samples per second — far too high-dimensional and variable-length to feed to a classifier directly. The standard speech front-end turns it into a compact, fixed-length descriptor in three stages: framing, time–frequency transform, and feature extraction + aggregation.

4.1 Framing

The signal $x(n)$ is cut into overlapping short frames so that each frame is approximately stationary (the vocal tract changes slowly, ~10 ms scale). We use

Nfft=512  (32ms window),H=160  (10ms hop), N_{\text{fft}} = 512 \;(\approx 32\,\text{ms window}), \qquad H = 160 \;(\approx 10\,\text{ms hop}),

with a Hann window $w(n) = 0.5\left(1 - \cos\frac{2\pi n}{N-1}\right)$ to reduce spectral leakage.

4.2 Short-Time Fourier Transform (STFT)

For frame index $m$ and frequency bin $k$,

X(m,k)  =  n=0Nfft1x(n+mH)w(n)ej2πkn/Nfft. X(m,k) \;=\; \sum_{n=0}^{N_{\text{fft}}-1} x(n + mH)\, w(n)\, e^{-\,j\,2\pi k n / N_{\text{fft}}}.

From it we form the magnitude $|X(m,k)|$ and power spectrogram

S(m,k)=X(m,k)2. S(m,k) = |X(m,k)|^2 .

The bin $k$ corresponds to physical frequency $f_k = \dfrac{k}{N_{\text{fft}}}, f_s$, with $f_s = 16,000$ Hz. Everything below is computed per frame $m$ and then aggregated over time (§6).


5. The features, in detail (with formulas)

We extract 12 groups of descriptors. They fall into three families:

  • Cepstral (MFCC + dynamics) — compact model of the spectral envelope (the vocal-tract shape that defines phonemes).
  • Spectral shape (centroid, bandwidth, roll-off, flatness, contrast) — interpretable scalar summaries of where and how spectral energy is distributed ("timbre").
  • Energy / harmonicity / time-domain (RMS, chroma, ZCR) — loudness, pitch-class content, and a rough voicing/noisiness cue.

5.1 Mel filterbank and log-mel energies

Human pitch perception is roughly logarithmic, captured by the mel scale

mel(f)=2595log10 ⁣(1+f700). \text{mel}(f) = 2595 \,\log_{10}\!\left(1 + \frac{f}{700}\right).

We place $M = 40$ overlapping triangular filters $H_j(k)$ equally spaced on the mel axis and integrate the power spectrum through them:

Emel(m,j)  =  kHj(k)S(m,k),j=1,,40. E_{\text{mel}}(m,j) \;=\; \sum_{k} H_j(k)\, S(m,k), \qquad j = 1,\dots,40 .

The dataset stores the log (dB) mel energies $;10\log_{10} E_{\text{mel}}(m,j);$ (columns mel0…mel39). Interpretation: a coarse, perceptually-warped picture of the spectral envelope — high values in low-mel bands mean energy concentrated at low pitch, etc.

5.2 Mel-Frequency Cepstral Coefficients (MFCC)

MFCCs decorrelate the log-mel vector with a Discrete Cosine Transform (DCT-II):

c(m,i)  =  j=1MlogEmel(m,j)cos ⁣[πiM(j12)],i=0,,19. c(m,i) \;=\; \sum_{j=1}^{M} \log E_{\text{mel}}(m,j)\, \cos\!\left[\frac{\pi i}{M}\left(j - \tfrac{1}{2}\right)\right], \qquad i = 0,\dots,19 .

We keep the first 20 coefficients (mfcc0…mfcc19). Low-order coefficients capture the smooth spectral envelope (formant structure → which phoneme is spoken); $c(m,0)$ is proportional to overall log-energy. MFCCs are the single most important speech feature historically and are nearly uncorrelated, which suits linear models well.

5.3 Delta ($\Delta$) and delta-delta ($\Delta\Delta$) coefficients

A single frame says nothing about motion. The delta features approximate the temporal derivative of each coefficient with a regression over $\pm\Theta$ frames:

Δc(m,i)  =  θ=1Θθ[c(m+θ,i)c(mθ,i)]2θ=1Θθ2. \Delta c(m,i) \;=\; \frac{\displaystyle\sum_{\theta=1}^{\Theta} \theta\,\bigl[c(m+\theta,i) - c(m-\theta,i)\bigr]} {\displaystyle 2\sum_{\theta=1}^{\Theta} \theta^{2}} .

The delta-delta (acceleration) features are the deltas of the deltas. Columns d1_0…d1_19 ($\Delta$) and d2_0…d2_19 ($\Delta\Delta$). Interpretation: how fast the spectrum is changing — crucial for distinguishing a short, dynamic spoken word from quasi-stationary noise or music.

5.4 Spectral centroid

The "centre of mass" of the spectrum — a strong correlate of perceived brightness:

centroid(m)  =  kfkX(m,k)kX(m,k). \text{centroid}(m) \;=\; \frac{\sum_{k} f_k \,|X(m,k)|}{\sum_{k} |X(m,k)|}.

5.5 Spectral bandwidth

The spread of energy around the centroid (here the $p=2$, i.e. standard-deviation, form):

bandwidth(m)  =  (kX(m,k)(fkcentroid(m))2kX(m,k))1/2. \text{bandwidth}(m) \;=\; \left( \frac{\sum_{k} |X(m,k)|\,\bigl(f_k - \text{centroid}(m)\bigr)^{2}} {\sum_{k} |X(m,k)|} \right)^{1/2}.

5.6 Spectral roll-off

The frequency $f_R(m)$ below which a fraction $\rho = 0.85$ of the total spectral energy lies:

fR(m)=min{fK  :  k:fkfKX(m,k)    ρkX(m,k)}. f_R(m) = \min\Big\{ f_K \;:\; \sum_{k:\,f_k \le f_K} |X(m,k)| \;\ge\; \rho \sum_{k} |X(m,k)| \Big\}.

Separates voiced/low-frequency-dominated frames from broadband/fricative ones.

5.7 Spectral flatness

The ratio of the geometric to the arithmetic mean of the power spectrum — a tonality vs. noisiness measure in $[0,1]$:

flatness(m)  =  exp ⁣(1KklnS(m,k))1KkS(m,k). \text{flatness}(m) \;=\; \frac{\exp\!\left(\frac{1}{K}\sum_{k}\ln S(m,k)\right)}{\frac{1}{K}\sum_{k} S(m,k)}.

A value near $1$ ⇒ white-noise-like (flat); near $0$ ⇒ tonal/harmonic (peaky), as in voiced speech. Very useful for telling speech from noise/music.

5.8 Spectral contrast

For each of 7 sub-bands $b$, the (log) difference between the strongest peaks and the weakest valleys in that band:

contrast(m,b)  =  Peakb(m)    Valleyb(m), \text{contrast}(m,b) \;=\; \overline{\text{Peak}}_b(m) \;-\; \overline{\text{Valley}}_b(m),

where the peak/valley terms are the mean log-energies of the top/bottom quantile of bins in band $b$. High contrast ⇒ clear harmonic structure (formants stand out over the noise floor). Columns contrast0…contrast6. In our baseline this was the single most informative group.

5.9 Chroma

Projects the spectrum onto the 12 pitch classes of the equal-tempered scale:

chroma(m,p)  =  k:pitch-class(fk)=pX(m,k),p=0,,11. \text{chroma}(m,p) \;=\; \sum_{k\,:\,\text{pitch-class}(f_k)=p} |X(m,k)|, \qquad p = 0,\dots,11 .

Octave-invariant harmonic content. Borrowed from music IR; for speech it is a weak but non-trivial cue. Columns chroma0…chroma11.

5.10 Zero-Crossing Rate (ZCR)

A cheap time-domain measure of how often the waveform changes sign within a frame of length $L$:

ZCR(m)  =  12Lnsgnx(n)sgnx(n1). \text{ZCR}(m) \;=\; \frac{1}{2L}\sum_{n}\bigl|\operatorname{sgn} x(n) - \operatorname{sgn} x(n-1)\bigr|.

High ZCR ⇒ noisy/fricative/unvoiced; low ZCR ⇒ voiced/low-frequency. A classic voicing proxy.

5.11 Root-Mean-Square energy (RMS)

Per-frame loudness:

RMS(m)  =  1Lnx(n)2. \text{RMS}(m) \;=\; \sqrt{\frac{1}{L}\sum_{n} x(n)^{2}} .

Tracks the speech envelope (syllable onsets/offsets, silences).


6. Temporal aggregation: variable-length audio → fixed vector

The features above produce one value per frame, so a clip is a matrix $\phi(m)$ of shape (features × frames), and clips have different numbers of frames (different durations). Classical models need a fixed-length vector. We therefore summarise each per-frame feature $\phi$ over its $T$ frames by its mean and standard deviation:

μϕ=1Tm=1Tϕ(m),σϕ=1Tm=1T(ϕ(m)μϕ)2. \mu_\phi = \frac{1}{T}\sum_{m=1}^{T} \phi(m), \qquad \sigma_\phi = \sqrt{\frac{1}{T}\sum_{m=1}^{T}\bigl(\phi(m) - \mu_\phi\bigr)^{2}} .

Hence every group contributes two columns per channel (…_mean, …_std), and every clip maps to the same 250-dimensional vector regardless of length. The std summaries turn out to be very informative — they encode how much the spectrum moves over time, which separates a short spoken word from stationary background. (In our baseline, several …_std features rank at the very top of tree-based feature importances.)

Design choice / leakage note. Clip duration is deliberately not a feature. In the raw corpus all podcast negatives are exactly 2.000 s while positives are shorter, so duration alone would let a model "cheat". Aggregating to mean/std makes the descriptor length-invariant and removes that shortcut. (The deeper synthetic-vs-real shortcut remains — see §8.)

Feature budget (250 total)

Group Per-frame channels × {mean, std} Columns
MFCC 20 2 40
$\Delta$ MFCC 20 2 40
$\Delta\Delta$ MFCC 20 2 40
log-mel energies 40 2 80
spectral contrast 7 2 14
chroma 12 2 24
centroid 1 2 2
bandwidth 1 2 2
roll-off 1 2 2
flatness 1 2 2
ZCR 1 2 2
RMS 1 2 2
Total 250

7. Dataset schema

One parquet file, 40 000 rows × 252 columns, all features float32, no missing values.

Column(s) Type Role Notes
mfcc{0..19}_{mean,std} float32 feature cepstral envelope
d1_{0..19}_{mean,std} float32 feature $\Delta$ MFCC
d2_{0..19}_{mean,std} float32 feature $\Delta\Delta$ MFCC
mel{0..39}_{mean,std} float32 feature log-mel energies (dB)
contrast{0..6}_{mean,std} float32 feature spectral contrast
chroma{0..11}_{mean,std} float32 feature pitch-class energy
centroid_{mean,std} float32 feature brightness
bandwidth_{mean,std} float32 feature spectral spread
rolloff_{mean,std} float32 feature 85 % roll-off freq.
flatness_{mean,std} float32 feature tonality
zcr_{mean,std} float32 feature zero-crossing rate
rms_{mean,std} float32 feature loudness
label int target 1 = «Акылай», 0 = negative
source string metadata positive / base_neg / confusable / podcastdo not train on this

Class balance: 10 000 positive / 30 000 negative (25 % positive, 1 : 3).


8. Modeling challenges

This is where the dataset earns its keep as a teaching tool. Things students should run into:

  1. Class imbalance → accuracy lies. A constant "always negative" classifier already scores 75 % accuracy but is useless (F1 = 0, PR-AUC = 0.25). Insist on precision, recall, F1, ROC-AUC, and especially PR-AUC, plus the confusion matrix. Tools to discuss: class_weight="balanced", threshold tuning, resampling.

  2. The synthetic-vs-real shortcut (the big one). Positives are TTS; podcast negatives are real human speech. A model can score deceptively well by learning "synthetic timbre vs. real" instead of "the word Akylai vs. other words". The antidote is per-source error analysis: evaluate false-positive rate separately on podcast, base_neg, and confusable. The honest difficulty lives in base_neg (same TTS voice, different word).

  3. Operating point & asymmetric costs. F1 is not the deployment metric; real KWS cares about recall at a fixed false-alarm rate. Sweep the threshold $\tau$ and read off the precision/recall trade-off — a natural lead-in to ROC and PR curves.

  4. Feature scaling matters — but only for some models. Distance/margin-based learners (Logistic Regression, SVM, k-NN) need StandardScaler; tree ensembles (Random Forest, Gradient Boosting) are scale-invariant. A clean side-by-side lesson.

  5. High dimensionality & redundancy. 250 features, many correlated (MFCC vs. mel; mean vs. std). Good ground for regularisation ($L_1/L_2$), feature importance, and dimensionality reduction. Note that in a 2-D PCA projection the classes overlap heavily — a useful reminder that "I can't see a boundary in 2-D" does not mean the classes are inseparable in 250-D.

  6. Speaker / generator leakage. Positives come from a limited set of synthetic voices; a purely random train/test split can leak speaker identity and inflate scores. A stricter evaluation would split by speaker or by source. Worth at least discussing.

  7. It's "easy enough" to be encouraging, hard enough to be real. Even a linear model reaches high PR-AUC on these features, so beginners get a rewarding result quickly — while the per-source breakdown leaves a genuine, interpretable hard core to dig into.


9. License, provenance & citation

  • License: Apache-2.0.
  • Languages: Kyrgyz (ky), with some Russian (ru) confusables.
  • Audio provenance: positives and base_neg are generated by an in-house Kyrgyz text-to-speech model (trained on podcast voices); confusable clips are generated by KaniTTS; podcast negatives are 2-second cuts of real Kyrgyz-language podcast speech. Features were extracted with librosa (16 kHz, $N_{\text{fft}}=512$, hop $=160$).
  • Parent project: the «Акылай» on-device wake-word detector (KaniTTS-research-team/AkylAi_Wake_Word_V4). This features table is a derived, tabular teaching snapshot — it does not contain audio.
@misc{akylai_kws_features,
  title  = {Akylai KWS Features: An Educational Spectral-Feature Dataset for Keyword Spotting},
  author = {AkylAi Wake Word project},
  year   = {2026},
  note   = {Derived tabular features (MFCC + spectral descriptors) over the Akylai wake-word corpus},
  license = {Apache-2.0}
}

Educational use. This dataset is intended for teaching classification and audio feature engineering. The synthetic positives and the domain split between TTS and real speech make it unsuitable as-is for benchmarking a production wake-word detector.