mocleiri / tensorflow-micropython-examples

A custom micropython firmware integrating tensorflow lite for microcontrollers and ulab to implement the tensorflow micro examples.
MIT License
170 stars 79 forks source link

Custom Spectrogram sizes using audio frontend #95

Open MATTYGILO opened 1 year ago

MATTYGILO commented 1 year ago

Hi I was wondering if it is possible to customise audio frontend to allow for different sample rates, stride size's and duration size's.

Also is audio frontend faster than ulab's fft

mocleiri commented 1 year ago

I just hard coded the spectrogram settings used on the reference example.

It's 100% possible to create a config object for the various settings and use it to change the settings used.

https://github.com/mocleiri/tensorflow-micropython-examples/blob/2c4573dbaf41dd391a15276bbe4bd9368ae169c4/micropython-modules/microlite/audio_frontend.c#L82

I.e. make a micropython config object to hold the settings and pass through into the reference example audio frontend at that point.

I didn't know enough at the start about how to use ulab to make the spectrogram.

You would probably need to retrain the network using the ulab spectrogram. I guess confirm the spectrogram is the same between bumpy ulab.

If you try using ulab I'd be happy to include it as one of the examples.