Esp32 i2s audio sampling rate drops while saving file using SPIFFS

Hi there, I'm using esp32-wroom-32e with inmp441 to record audio and save it using SPIFFS. My goal is to send the audio via WIFI and get a response to play. Weird thing is after two conversations, the i2s recording sample_rate drop and the bytes read are almost half of the normal one.

I did delete the old audio at the beginning of each conversation but it didn't work.
I also tried not saving the file and the problem fixed, but thats not what my program was supposed to work.

I did check usage of SPIFFS, my totalBytes is around 1400000bytes, my file is usually around 200000bytes, but the sampling rate still gets buggy after 2-3 conversations.

Can someone give a hint or point a direction? I appreciate all the help. Thanks.

Not sure I understand exactly, but it sounds like as you have more data in spiffs it takes longer to complete it's action and that afects the sampling rate.

Are you sure the problem is the spiffs? Are you checking the size of the file creating it?

i2s works fine if I don't save the file. But when i save the file(file size takes around 20% of the SPIFFS space), real time sample rate drops.

No, I try not saving the file using SPIFFS and the problem solved, but it could be coincident.
Yes, I check the file size, it never reach the max limit of SPIFFS.

I would post the code later when I got my laptop.

If I have to read minds (since there is no code), you are losing samples. There is no change in sample rate.

Try with 16 bits at 4-6-8 khz sample rate.Your code might be a bit slow to save the data in time.

Try using psram already included in your board.

1 Like

The SPIFFS write is very likely blocking.

SOLVED. YES 8 khz is good for at least ten conversations.

But I can't figure out the theory deep down. I did output the process of saving data to serial and it seems like it doesn't take long to save the data in time. Is there a way to monitor the actual saving process?

use millis() to check that.

Your code is wrong anyways. With 4mb of ram you should save the data to ram, then to a file.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.