element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi-Fest
  • Challenges & Projects
  • Design Challenges
  • Pi-Fest
  • More
  • Cancel
Pi-Fest
Blog Songspire - experimenting with BirdNET
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Leaderboard
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: feiticeir0
  • Date Created: 26 Jul 2022 5:07 PM Date Created
  • Views 2357 views
  • Likes 7 likes
  • Comments 1 comment
  • songspire
  • birdnet
  • Pi-Fest Design Challenge
  • birdnet inference
  • raspberry pi pico
  • birdnet installation
  • pifest
  • pi-fest
  • pi-fest songspire
  • birdnet installation raspberry pi
Related
Recommended

Songspire - experimenting with BirdNET

feiticeir0
feiticeir0
26 Jul 2022
Songspire - experimenting with BirdNET

imageBirdNet logo

Hi everyone !  Hope all are fine.

Today, we're going to try BirdNet. I've already introduced it in my last post. They have a Github repository where they have some script to process simple audio files using the models  that anyone can use .

Today, we're going to install it on a Raspberry PI 4 and analyze some recordings - as well some I've already done - and see what we get ; If we get something. Smiley

BirdNet on a Raspberry PI 4

First, I'm going to try BirdNet model on a Raspberry PI. They already have the tools build to run inference on the audio files.

Why try here first ?

Because this way, I get a sense on the workings of the model and see if the audio files need some, or have some processing before being submitted to the model . It's like a trial run before going for a small device like the Pico.

If the files need some processing, what kind of processing ? Can the Pico do this ? These are the kind of questions that need answers.

Installation

Python3 must be the default version.

Let's create a virtual environment with PIP to install and use birdNet.

Install some packages

sudo apt-get install python3-pip ffmpeg python3-venv

Create the virtual environment

python -m venv birdNet

activate the virtual environment

source birdNet/bin/activate

We know we have it active, because the name it's appended to the bash

image

Let's now install some more packages with PIP

update PIP

python -m pip install --upgrade pip

Install wheel because it helps

pip install wheel

pip install librosa tflite-runtime

If everything goes smoothly, we have what we need to start using the model to discover what bird is singing.

Clone the git repository and enter it

sudo apt-get install git

git clone https://github.com/kahst/BirdNET-Analyzer.git

cd BirdNet-Analyzer

Now, let's try to analyze some samples - they have an example directory that we can use.

Let's see what's inside the directory

ls example/

image

They have an audio wave with some samples (I've attached it to this post for your consultation), a txt file with some species (species_list.txt) and the result of the analysis of the wave file in a file called soundscape.BirdNET.selection.table.txt.

We can delete this file . This is the result generated when using the example audio.

To analyze the file and see what birds are in the sound file, just issue the command:

python analyze.py (in the root of the directory)

Without any arguments, it uses the example directory

image

But, this is where it gives an error

(birdNET) pi@raspberrypi:~/birdNET/BirdNET-Analyzer $ python analyze.py
Species list contains 2434 species
Found 1 files to analyze
Analyzing example/soundscape.wav
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/pi/birdNET/BirdNET-Analyzer/analyze.py", line 238, in analyzeFile
    chunks = getRawAudioFromFile(fpath)
  File "/home/pi/birdNET/BirdNET-Analyzer/analyze.py", line 206, in getRawAudioFromFile

The error is long, but the main issue I'm guessing it's here:

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Internal error at <numba.core.typeinfer.CallConstraint object at 0xaa8cccb8>.
Failed in nopython mode pipeline (step: native lowering)
The 'parallel' target is not currently supported on 32 bit hardware.

The bullseye version that I'm running is 32bits.

There's nothing on the BirdNET documentation  about this.

I've tried it on my computer (Arch Linux x86_64) and everything went well.

image

Now, we have the same files already listed above with the species found on the wave file. This is just an example:

image

The last column is the confidence the model has about a specific bird .

Solving the Raspberry PI problem

To solve this, I went and installed the 64bit version of the bullseye .

image

pi@raspberrypi:~ $ uname  -a
Linux raspberrypi 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux

After updating for the 64bit version, here's the result :

image

It worked flawlessly . A bit slow (compared with my machine), but it worked.

Now that we have the BirdNET working, let's analyze some personal samples.

For this project, I've collected some audio recordings from birds around me - anytime I could . I have 3 samples, recorded with my mobile phone.

I've created another directory, called example2, with the recordings.

Because the BirdNET analyzer.py only works with certain audio files, I've converted the aac files to wav using faad.

for i in *.aac; do faad $i; done

Now I also have the files in wav format.

Let's see what the BirdNET detects

We can give a directory as input and a directory as output also, where it will keep the text file with the results. Remember, you need the virtual environment active.

python analyze.py --i example2/ --o example2/

Species list contains 2434 species
Found 3 files to analyze
Analyzing example2/sample1.wav
Analyzing example2/sample2.wav
Analyzing example2/sample3.wav
INFO: INFO: INFO: Created TensorFlow Lite XNNPACK delegate for CPU.Created TensorFlow Lite XNNPACK delegate for CPU.
Created TensorFlow Lite XNNPACK delegate for CPU.

Finished example2/sample2.wav in 49.35 seconds
Finished example2/sample1.wav in 49.43 seconds
Finished example2/sample3.wav in 49.60 seconds

Let's see what we got.

cd example2

ls

image

For each wav file, we have a text file with the results - that are the identification of the birds singing.

Those are recordings of house sparrows - "Pardais" like we call them here in Portugal.

These results are amazing. If you hear the recordings, especially sample3, there's a lot of noise in the background. Call me impressed.

This is a new example, from a earlier post of mine - /challenges-projects/design-challenges/pi-fest/b/blog/posts/songspire---data-augmentation-for-audio with a Cuckoo recording.

(birdNET) pi@raspberrypi:~/birdNET/BirdNET-Analyzer $ python analyze.py --i example2/Cuckoo.wav --o example2/Cuckoo.txt
Species list contains 2434 species
Analyzing example2/Cuckoo.wav
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Finished example2/Cuckoo.wav in 28.32 seconds

And the result is:

(birdNET) pi@raspberrypi:~/birdNET/BirdNET-Analyzer/example2 $ cat Cuckoo.txt
Selection    View    Channel    Begin Time (s)    End Time (s)    Low Freq (Hz)    High Freq (Hz)    Species Code    Common Name    Confidence
1    Spectrogram 1    1    0    3.0    150    12000    comcuc    Common Cuckoo    0.9995
2    Spectrogram 1    1    3.0    6.0    150    12000    comcuc    Common Cuckoo    0.9978

with a confidence of almost 1. Perfect !

Next steps

Now that I know that the BirdNET works well in identifying the birds, the next step is to record audio on the Pico . Without that, we have nothing.

Stay tuned !

Resources

https://github.com/kahst/BirdNET-Analyzer

Play this audio clip

Play this audio clip

Play this audio clip

  • Sign in to reply
  • DAB
    DAB over 3 years ago

    Very nice.

    I look forward to your next post.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube