Skip to content

audiofeatures: speech features for a wake word model - #334

Merged
bdbarnett merged 3 commits into
mainfrom
audiofeatures
Oct 29, 2026
Merged

bdbarnett merged 3 commits into
mainfrom
audiofeatures

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

A new module, audiofeatures: every 10 ms of audio becomes a slice of 40 mel-band values, the input a microWakeWord model takes.

  • The frontend is TensorFlow Lite Micro's audio microfrontend (Apache-2.0, third_party/microfrontend) with the kissfft it uses (BSD-3-Clause, third_party/kissfft), both unchanged. src/shared/audiodsp_microfrontend.c compiles them as one C file with every symbol renamed, and replaces the three C++ glue files with C, so no target needs a C++ compiler.
  • Settings are ESPHome's micro_wake_word ones; readinto() gives the int8 those models take, readinto_raw() the frontend's uint16.
  • 16 kHz goes straight to the frontend and is byte-identical to the reference C++ build in every block size; the goldens in tests/data/audiofeatures were written by that build.
  • Other rates (16 to 384 kHz, any channel count) go through a Kaiser windowed-sinc resampler: flat to 7.5 kHz, about 70 dB down from 8.5 kHz.
  • MicroPython (make and CMake) and the CPython wheel; not CircuitPython, like audiometer. attach(tap, rate) reads an audiopump.Tap in C on MicroPython.
  • examples/audiofeatures_simpletest.py prints a WAV's slices; docs/guides/speech-features.md explains the module; tests/parity/features_probe.py holds every interpreter to the same bytes.

… rate

TensorFlow Lite Micro's audio microfrontend with microWakeWord's settings,
carried in third_party with the kissfft it calls and built as one C
translation unit. 16 kHz audio gives the reference build's bytes exactly;
other rates go through a windowed-sinc resampler to 16 kHz first. feed()
from Python anywhere, attach() to an audiopump.Tap on a board. Not built
into CircuitPython, like audiometer.
The resampler's taps came from sin(), which may differ in the last bit
between C libraries, and the unix MicroPython build in CI made different
48 kHz features from the CPython wheel. sin(pi x) is now a series in exact
IEEE arithmetic, and both files take audiodsp_fp_contract.h like the rest
of src/shared. The symbol test needs GNU nm, so it runs on Linux only.
@bdbarnett
bdbarnett merged commit b99ed7f into main Oct 29, 2026
32 checks passed
@bdbarnett
bdbarnett deleted the audiofeatures branch October 29, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant