mp3micropythonadcraspberry-pi-pico

how to turn raw audio output from analog microphone into mp3 file?


I am working with a RPI Pico w, I have an analog microphone connected correctly and outputting raw audio data, how do I convert it into a file I can listen to?? I am using the micro python language.


Solution

  • here is what I did to solve it:

    with open("/sd/audio.wav", "wb") as f:
        print("open")
        for i in range(10000):
            sample = adc.read_u16()
            buffer.append(sample)
            if(len(buffer) == 1000):
                f.write(bytearray(buffer))
                buffer = []
                print("done")
            utime.sleep(0.001 )
    

    you just gotta open it and write to it.

    thank you!