Skip to content

Raspberry Pi Audio Recording with Python

Panday Swarnam (IFIN DES PTS TI EA DE) edited this page Oct 12, 2022 · 1 revision

In this tutorial you learn how to do basic audio recording with our I2S microphones and Python.

Requirements

The first step is to go through this guide and make sure that I2S is running on your Raspberry Pi and the I2S microphone is connected.

Apt Packages

For the required Pip packages ATLAS, pyaudio and the ALSA development package are required:

sudo apt-get install libatlas-base-dev libportaudio2 libasound-dev

For communication between our microphone and Python we use the python-pyaudio library. It can be installed using the following command:

sudo apt-get install python-pyaudio

Running the example

You can find the example in this GitHub repo at application_examples/raspberrypi/audio_processing/basic_audio_recording.py. To run the example, please clone the repository locally on your Raspberry Pi.

Before running the example please open it and read the comments to understand what it does. You can run the example by typing

python3 basic_audio_recording.py

on your Raspberry Pi.