I am currently building a light-weighted audio system using my rasperry Pi zero.

I am looking to enable my Pi to have the following 2 functionalities:

1) be able to record from a microphone

2) be able to play back from what is recorded.

I am wondering if you guys know any off the shelf code (perferrably written in C) that I can use, to enable my Pi to have the following functionalities?

2 Answers 2


The Pi Zero doesn't have a built-in Microphone input nor Audio output, therefore, you will need either a USB Sound Card or a pHAT. In case it helps, I bought a "USB Sound Card for Pi" on ebay for $3, which has two inputs, mic and stereo jack, and I use Audacity on the Pi to record and play audio, and it works great. If you already have all the necessary hardware and want to 'program' a way to record and then play the recording, I would recommend looking into PyAudio in Python.

  • Yes, I am looking for a coding version to record the video. I will look into Pyaudio. If you know anything written in C, I would love to know as well. Thanks! Commented Aug 2, 2017 at 4:19

PyAudio, mentioned by user3222184 is just a python wrapper for PortAudio (http://portaudio.com/), which can definitely be used to do what you want. It's a cross-platform C / C++ library.

I've use PyAudio with PortAudio on a Raspberry Pi, so I know that it works. It can be tricky if you're trying to do any audio processing to ensure that the processing runs fast enough to keep up with real-time audio, but that won't be an issue for simple recording and playback.

PortAudio won't write mp3 files itself. It does understand wave files, and I don't know off the top of my head what other formats it may support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.