Skip to content

Raspberry Pi Audio Processing with Python

Veronika Stellwag edited this page May 10, 2021 · 6 revisions

In this tutorial you learn how to do basic audio processing 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, PortAudio and the ALSA development package are required:

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

Pip Packages

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

python3 -m pip install --user sounddevice

To be able to write our audio segments to wav files we need to install SciPy:

python3 -m pip install --user scipy

Running the example

You can find the example in this GitHub repo at application_examples/raspberrypi/audio_processing/basic_audio_processing.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_processing.py

on your Raspberry Pi.