espressif / esp-tflite-micro

TensorFlow Lite Micro for Espressif Chipsets
Apache License 2.0
395 stars 85 forks source link

Adapt micro_speech to use a 24bit microphone? #59

Closed OOHehir closed 1 year ago

OOHehir commented 1 year ago

Hello,

This is a question rather than an issue. I'm trying to use the SPH0645 microphone. According to the datasheet for this device:

The Data Format is I2S, 24 bit, 2’s compliment, MSB first. The Data Precision is 18 bits, unused bits are zeros.

The micro_speech examples expects 16 bit PCM sample data.

My questions is do you know if the code has been successfully modified to accept 24 bit data? I thought the quickest solution would be to down-sample the input to 16 bit. The longer solution would be get a model trained for 18 bits & adapt the code.

Any thoughts you have on the approaches would be appreciated.

Regards,

vikramdattu commented 1 year ago

Hello @OOHehir the example do expect 16 bit samples. That is because, the featureGenerator we use is only implemented for 16 bit input. The model itself doesn't work directly on PCM data but the features generated from the PCM data. Hence, the model should not need to be redesigned for this reason.

As you've guessed, to work with existing example, you either have to convert the speech data to 16 bit samples, which then can be used to generate features (GenerateMicroFeatures function), OR modify the generator function to work with different bit-width data directly.

OOHehir commented 1 year ago

Many thanks for the quick response, I'll look at the options you suggested.