Acoustic monitoring of ecosystems is an efficient and non invasive method that allow us to collect data continuously and remotely in the ecosystems. Using this data we can tell a lot about what is happening in our parks, reserves and conservancies. Birds vocalize a lot and also respond quickly to enviromental changes making them to be an ideal indicator species for acoustic monitoring of the biosphere.
The idea behind acoustic classification of birds is that birds produce characteristic calls/songs that are unique to their species. We can tell different species of birds by just listening to the sound they produce. Acoustic data is collected by deploying acoustic sensors in the field. From analysis of this data, we can assess the state of our ecosystems. A lot of data is collected by the acoustic sensors. Manual classification of this data may turn to be a difficult task. However, we can automate the process by using acoustic sensors that automatically classify the recordings they capture. These sensors are loaded with machine learning models that have been pretrained on birds acoustic data for the classification.
Sound produced by a given bird species sounds differently from sound from another species due to difference in frequency components of these sounds. If we can extract the frequency components of a sound, we can be able to describe that sound. Sounds produced by birds of the same species will have frequency components that are unique to that species. Therefore, we can differentiate different birds species by analyzing the frequency components of the sounds they produce. A spectrogram ( a plot of frequency against time) is used to visualize the frequency components of sound.
Figure 1: Spectrograms of a Grey-backed Camaroptera (left) and Hartlaub's Turacos (right)
Figure 1 above shows spectrograms of a Greybacked Camaroptera and a Hartlaub's Turacos. By looking at the two spectrograms, we can see that the frequency composition of the sounds from the two birds are different. We can then treat the spectrograms as images and use them to train machine learning models for classification.
Figure 2: A flow diagram of how acoustic classification of bird species is acheived.
After training a model, we can then deploy it on an acoustic sensor for automatic acoustic classification of birds in the ecosystems.
Acoustic data is required to train machine learning models for automatic acoustic classification of birds. At DSAIL, we have developed a Raspberry Pi based recording system to collect acoustic data of birds (DSAIL Bioacoustics System). The system is designed to continuously 'listen' waiting for acoustic activities. Segments of stream that exhibit acoustic activities are saved as audio files in the Raspberry Pi's storage. The program data_collection.py
enables the Raspberry Pi to make the recordings. The flow chart below shows the working of the program.
Figure 3: A flow chart of the data collection program.
The following steps outline how to prepare the Raspberry Pi for data collection.
- Raspberry Pi 3/4
- Raspberry Pi power supply
- USB microphone
- An SD Card loaded with Raspberry Pi OS
- Access to the internet.
- Ability to access the Raspberry Pi's command line.
Power the Raspberry Pi and access its commandline. Ensure the Raspberry Pi is connected to the internet. Let's begin by cloning this repository. Run the following command on the Raspberry Pi's terminal:
git clone https://github.com/DeKUT-DSAIL/bioacoustics
Next run the following commands to create a virtual environment and install the requirements:
/home/pi/bioacoustics/raspi_setup.sh
Before we start collecting data, let's increase the gain of the microphone. Follow the instructions below to increase the gain of the microphone:
alsamixer
Next, press F6
to list the available recording devices. Scroll down to the microphone you intend to increase the gain of using the up-down
navigation keys. For my case it is the USB PNP Sound Device
as shown below.
Press Enter
. Next press F5
and then using the left
navigation key to select the MIC
option as shown below:
Next increase the mic gain to the desired gain using the up
navigation key.
To start data collection, run the following command.
/home/pi/bioacoustics/audio.sh
If you intend for the program to run every time on boot, we will need to schedule it in crontab
. Run the following the command:
crontab -e
If it is the first time using crontab, you will be prompted to choose an editor. Choose nano editor by entering 1. Copy and paste the following in the crontab:
@reboot /home/pi/bioacoustics/audio.sh
The system is now ready for data collection.