Librosa (Log)MelSpectrogram on GAP

This project shows how to implement a Librosa-like MelSpectrogram feature extraction on GAP. Look at the nntool_librosa.ipynb notebook for more details on the implementation. The app in main.c is derived from the template project generated by the notebook and is used to run the feature extraction on an input file. The output is then saved in a binary file that can be read and compared with Librosa ground truth with the compare.py script.

The code supports different data type and frame sizes/hop/number of mels and also to enable the log or output just the mel spectrogram. You can test it first in the nntool_librosa.ipynb notebook and then run it on GAP by changing the Kconfig options.

Limitations

In Gapflow the STFT is implemented with an FFT (not DFT), hence the n_fft must be always a power-of-2.

How to run

To run the code with default settings (DATA_TYPE=float32 - FRAME_SIZE=512 - FRAME_STEP=160 - N_MELS=128) just type:

mkdir build && cd build && cmake ../
make run -j

Use make menuconfig to change the Kconfig options.

Once the application run, you can check the output binary file with:

mkdir build && cd build && cmake ../
make compare_vs_librosa