4.1. Neural Network Architectures
Three original, compact architectures were designed, trained, and evaluated: a CNN, belonging to the family introduced by Sainath and Parada [
6]; a CRNN, following the design of Arik et al. [
7]; and a DS-CNN inspired by the architecture proposed in [
3]. In addition, the BC-ResNet architecture [
8] was reimplemented as a state-of-the-art reference for benchmarking. All models were engineered to process two-dimensional MFCC features as input. Each architecture was kept within a small-footprint budget suitable for microcontroller deployment, ranging from approximately 13k parameters for the BC-ResNet reference to 76k for the CNN (
Table 1). As discussed in
Section 5, parameter count alone is not predictive of accuracy in this regime: the largest model (CNN) is in fact the least accurate, indicating that the inductive bias of each architecture family, rather than raw capacity, is the dominant factor.
The CNN model is designed to function as an acoustic feature extractor. The model architecture is shown in
Figure 3. The architecture utilizes standard two-dimensional convolutional layers to capture local time–frequency correlations, such as formants and pitch shifts. The multidimensional output is subsequently flattened and processed through fully connected dense layers, culminating in a softmax classifier that outputs the target vocabulary probabilities.
To better capture the sequential nature of speech, a hybrid CRNN architecture was implemented (
Figure 4). The initial convolutional layer forms a spatial front end that reduces the input dimensionality. Next, the spatial dimensions are flattened while the temporal axis is preserved, forming a time-series representation. This is fed into a single GRU layer with 32 units (see
Figure 4), which allows the model to capture long-term phonetic dependencies. The final layer is a dense classification layer with a softmax activation function.
The DS-CNN architecture design is based on [
3]. Model structure is shown in
Figure 5. The model contains 4 DS blocks (
Figure 6). Each block consists of a depthwise phase and a pointwise phase. In the depthwise part, a spatial filtering step applies a
kernel independently to each input channel. It is followed by batch normalization for training stabilization and a ReLU activation function. In the pointwise part, a
convolution is used to linearly combine the feature maps generated by the depthwise phase into output channels. As in the first phase, it is followed by batch normalization and a ReLU activation function. Formally, a depthwise separable convolution factorizes a standard convolution into a depthwise and a pointwise step. For an input with
channels,
output channels, and a
kernel applied to feature maps of spatial size
, a standard convolution costs
multiply–accumulate operations, whereas the depthwise separable form costs
. The resulting reduction factor is
which, for the
kernels used here, gives close to a ninefold reduction in cost and motivates the use of the DS-CNN for microcontroller deployment.
For completeness, we give the forward-propagation equations of the three proposed models, using the notation of
Section 3 (input
, logits
, and posteriors
from Equation (
1)).
CNN. With
, each convolutional layer
computes
where ∗ denotes two-dimensional convolution. Max pooling and flattening yield
, which two fully connected layers map to the logits,
CRNN. A single convolution and pooling stage produces a feature map that is reshaped along the time axis into a sequence
with
. For
, the 32-unit GRU with hidden state
updates
where
is the logistic sigmoid and ⊙ the Hadamard product. The final hidden state gives the logits
.
DS-CNN. An initial standard convolution produces
. Each DS block
applies a depthwise (
) and then a pointwise (
) convolution, each followed by batch normalization (
) and a ReLU activation,
Global average pooling over the spatial dimensions
yields
, which a dense layer maps to the logits
.
While each architecture follows an established family, the specific instantiations reported here constitute our design contribution. For the CNN, we adopt a three-layer convolutional stack with decreasing channel widths (16, 8, 5) followed by a two-layer classifier, trading depth for a small parameter count. For the CRNN, we reduce the convolutional front end to a single convolution–pooling stage feeding a single 32-unit GRU, which we found sufficient to model the temporal context of one-second commands at minimal cost. For the DS-CNN, we fix four depthwise-separable blocks with a channel multiplier of 64 and no inter-block spatial downsampling, prioritizing accuracy retention under quantization. All three architectures were tuned to a comparable budget on the order of
parameters, such that the cross-architecture comparison in
Section 5 reflects inductive bias rather than raw capacity. The exact per-layer configurations, which are the design variables we set, are given in
Figure 3,
Figure 4 and
Figure 5, and the resulting parameter counts in
Table 1.
The feature-extraction and input hyperparameters were chosen to match the dataset and the microcontroller budget rather than tuned to the target language. Each one-second clip is represented by a MFCC matrix (61 time frames of 40 coefficients). The MFCC front end uses 40 Mel filter banks spanning 64–8000 Hz, a 512-point FFT at a 16 kHz sampling rate, and 50% frame overlap; the 512-point window corresponds to a frame length of 32 ms, and the 50% overlap gives a frame shift of 16 ms, which yields frames per one-second clip. A single static feature stream, without delta or delta-delta coefficients, was retained to limit the input size and the resulting model and tensor-arena memory on the RP2350. We did not tune the number of Mel filters, the number of coefficients, or the frame length and shift to the Polish phoneme inventory, nor did we evaluate dynamic (delta) features. Because Polish phoneme confusability is concentrated in fine spectral detail (owing to its rich fricative and sibilant inventory), a targeted study of these feature choices, including a higher Mel resolution and the addition of delta coefficients, is a promising route to better discrimination of pairs such as “ptak”/“tak” and is left for future work. Similarly, the 32-unit GRU of the CRNN was sized to meet the shared parameter budget rather than selected by an exhaustive search; we did not systematically explore whether a larger recurrent state would improve accuracy at the cost of latency or whether performance is already saturated on this 25-word vocabulary.
The complete on-device inference pipeline is summarized in Algorithm 1; the Float32 and INT8 variants differ only in the input-quantization step.
The CNN, CRNN, and DS-CNN models were trained using the Adam optimizer with sparse categorical cross-entropy loss over a maximum of 20 epochs, with a batch size of 64 or 128 (model-dependent) and early stopping (patience = 3, restoring best weights). Because early stopping restored the weights from the epoch of lowest validation loss, the 20-epoch cap acts only as an upper bound: the reported accuracies correspond to the best-validation (converged) checkpoint rather than to premature stopping. The learning curves are available in
Appendix B.
| Algorithm 1 On-device keyword-spotting inference on the RP2350. |
Require: raw audio frame s (1 s, 16 kHz); trained model (Float32 or INT8); threshold ; for the INT8 model, input scale S and zero point Z Ensure: recognized keyword or reject- 1:
▹ pre-emphasis, framing, windowing, FFT, Mel filter bank, log, DCT (CMSIS-DSP) - 2:
if is INT8 then - 3:
▹ quantize MFCC input to 8-bit - 4:
▹ integer forward pass (TFLite Micro/CMSIS-NN); logits dequantized to - 5:
else - 6:
▹ floating-point forward pass - 7:
end if - 8:
p ← softmax ▹ Equation ( 1) - 9:
- 10:
if then - 11:
return keyword - 12:
else - 13:
return reject ▹ background noise or unknown word - 14:
end if
|
The BC-ResNet model followed the training procedure from the original paper [
8]: an SGD optimizer with momentum 0.9, L2 weight decay 0.001, an initial learning rate of 0.1 with a 2-epoch warmup and cosine/stepwise decay, over 20 epochs with a batch size of 128. The three proposed models were thus trained under identical conditions so that comparisons among them (the primary object of this study) are controlled. The BC-ResNet reference was instead trained according to its authors’ procedure to reproduce its reported state-of-the-art behavior faithfully; imposing our generic training setup on it could have handicapped the reference and caused its performance to be underestimated. We note that this difference in training protocol is a confounding factor for the BC-ResNet comparison specifically, which we discuss further in the limitations (
Section 6).
The dataset was partitioned into a training subset (80%, 112,677 samples) and a test subset (20%, 28,169 samples) using a fixed random seed. The split was not explicitly speaker-independent. Fivefold cross-validation was applied on the training subset for model selection; final accuracy was evaluated on the shared test set.
Regularization was applied in the form of early stopping on validation loss (CNN, CRNN, DS-CNN) and L2 weight decay (BC-ResNet). Data augmentation in the form of white noise injection was applied to the training set only; additional augmentations (pitch shifting, time stretching, and noise) were provided by the dataset authors. All training was performed in TensorFlow 2.10.1/Keras 2.10.0 (CNN, CRNN, DS-CNN) and PyTorch 2.5.1 (BC-ResNet) on a single NVIDIA GeForce GTX 1050 Ti GPU. The BC-ResNet model was subsequently exported to TensorFlow, such that all four models share an identical conversion, INT8 quantization, and on-device inference path; the only difference for BC-ResNet is thus on the training side (framework and procedure), not in the quantization or inference pipeline.
The total number of parameters for each architecture is summarized in
Table 1.