The Joy of BirdNetPi

I don’t think I’ve had as much enjoyment for a piece of software for a very long time as I’ve had with BirdNET-Pi. It’s a realtime acoustic bird classification system for the Raspberry Pi. It listens through a microphone you place somewhere near where you can hear birds, and it’ll go off and guess what it’s hearing, using a cut-down version of the BirdNET Sound ID model. It does this 24/7, and saves the samples it hears. You can then go to a web page (running on the same Raspberry Pi) and look up all the species it has heard.

Our Garden

a somewhat overgrown garden with budding green trees against blue sky

Not very impressive, kind of overgrown, in the wrong part of town. Small, too. But birds love it. At this time of year, it’s alive with birds. You can’t make them out, but there’s a pair of Rose-breasted Grosbeaks happily snacking near the top of the big tree. There are conifers next door too, so we get birds we wouldn’t expect.

We are next to two busy subway/train stations, and in between two schools. There’s a busy intersection nearby, too. Consequently, the background noise is horrendous

What I used

This was literally “stuff I had lying around”:

  • Raspberry Pi 3B+ (with power supply, case, thermostatic fan and SD card)
  • USB extension cable (this, apparently, is quite important to isolate the USB audio device from electrical noise)
  • Horrible cheap USB sound card: I paid about $2 for a “3d sound” thing about a decade ago. It records in mono. It works. My one is wrapped in electrical tape as the case keeps threatening to fall off, plus it has a hugely bright flashing LED the is annoying.
  • Desktop mic (circa 2002): before video became a thing, PCs had conferencing microphones. I think I got this one free with a PC over 20 years ago. It’s entirely unremarkable and is not an audiophile device. I stuck it out a back window and used a strip of gaffer tape to stop bugs getting in. It’s not waterproof, but it didn’t rain the whole week it was out the window.
  • Raspberry Pi OS Lite 64-bit. Yes, it has to be 64 bit.
  • BirdNET-Pi installation on top.

I spent very little time optimizing this. I had to fiddle with microphone gain slightly. That’s all.

What I heard

To the best of my knowledge, I have actual observations of 30 species, observed between May 7th and May 16th 2023:

American Goldfinch, American Robin, Baltimore Oriole, Blue Jay, Cedar Waxwing, Chimney Swift, Clay-colored Sparrow, Common Grackle, Common Raven, Gray Catbird, Hermit Thrush, House Finch, House Sparrow, Killdeer, Mourning Dove, Nashville Warbler, Northern Cardinal, Northern Parula, Orchard Oriole, Ovenbird, Red-winged Blackbird, Ring-billed Gull, Rose-breasted Grosbeak, Ruby-crowned Kinglet, Song Sparrow, Veery, Warbling Vireo, White-throated Sparrow, White-winged Crossbill, Wood Thrush

I’ll put the recordings at the end of this post. Note, though, they’re noisy: Cornell Lab quality they ain’t.

What I learned

This is the first time that I’ve let an “AI” classifier model run with no intervention. If it flags some false positives, then it’s pretty low-stakes when it’s wrong. And how wrong did it get some things!

allegedly a Barred Owl, this is clearly a two-stroke leafblower
Black-Billed Cuckoo? How about kids playing in the school yard?
Emergency vehicles are Common Loons now, according to BirdNetPi
Police cars at 2:24 am are Eastern Screech-Owls. I wonder if we could use this classifier to detect over-policed, under-served neighbourhoods?
Great Black-backed Gulls, or kids playing? The latter
Turkey Vulture? How about a very farty two-stroke engine in a bicycle frame driving past?
(This thing stinks out the street, blecch)

There are also false positive for Trumpeter Swans (local dog) and Tundra Swans (kids playing). These samples had recognizable voices, so I didn’t include them here.

The 30 positive species identifications

Many of these have a fairly loud click at the start of the sample, so mind your ears.

American Goldfinch

American Robin

Baltimore Oriole

(I dunno what’s going on here; the next sample’s much more representative)

Blue Jay

Cedar Waxwing

Chimney Swift

Clay-colored Sparrow

Common Grackle

Common Raven

Gray Catbird

Hermit Thrush

House Finch

House Sparrow

Killdeer

Mourning Dove

Nashville Warbler

Northern Cardinal

Hey, we’ve got both of the repetitive songs that these little doozers chirp out all day. Song 1:

and song 2 …

Northern Parula

Orchard Oriole

Ovenbird

Red-winged Blackbird

Ring-billed Gull

Rose-breasted Grosbeak

Ruby-crowned Kinglet

Song Sparrow

Veery

Warbling Vireo

White-throated Sparrow

White-winged Crossbill

Wood Thrush

Boring technical bit

BirdNetPi doesn’t create combined spectrograms with audio as a single video file. What it does do is create an mp3 plus a PNG of the spectrogram. ffmpeg can make a nice not-too-large webm video for sharing:

ffmpeg -loop 1 -y -i 'birb.mp3.png' -i 'birb.mp3' -ac 1 -crf 48 -vf scale=720:-2 -shortest 'birb.webm'

Mockingbird in the Rain

Northern Mockingbird (Mimus polyglottos) recorded at Centennial College Ashtonbee campus parking lot near Wexford Woods, 07:52 2020-04-13 (rain, handheld phone, noise filtered)

I went out for a very soggy bike ride this morning just to get out of the house. There were a few more people out than I expected, as it’s a regular work day for most people in Ontario. COVID-19 meant that most workplaces were shuttered.

Splashing through the puddles at Centennial College’s deserted Ashtonbee campus (round about here, if you need a precise location) I heard this mockingbird giving its very best performance. I only got a little over a minute of it, but in that time there was some American Robin, Gull, hawk of some kind and best of all (starting just after 40 s) car alarm.

Centennial’s got a big automotive section, and the empty parking lot’s usually full of cars. Mimus was just repeating what it usually heard. I wonder how long they’ll remember and replay car alarms after we’re gone?

birb chirper v2.0

This is one of those toys that you whirl around on a piece of string and it makes a chirping sound like a flock of sparrows. I have no idea what they’re called, so I called it birb_chirper.

Print Settings

Printer: Reach 3D
Rafts: Doesn’t Matter
Supports: Doesn’t Matter
Resolution: 0.3 mm
Infill: 0%

Notes: This is a thin-walled model, so use at least two shells and no infill for smooth walls.

Post-Printing

Take a piece of thin string about 1 metre long (I used micro-cord, very fine paracord), pass it through the hole in the tip, then tie off a jam knot that’s big enough to stop in the hole in the top but still pass back through the slot in the side. Now whirl the thing around fast by the string, and it should start to chirp.

This is intended for the amusement of small children and the annoyance of adults.

How I Designed This

The tip of this thing is an ogee curve. I’ve included my library for creating simple ogee and ogive profiles in OpenSCAD.

// ogive-ogee example
// scruss, 2018
use <ogive_and_ogee.scad>;
ogive(20, 35);
translate([0, -5])text("ogive(20,35)", size=3);
translate([30, 0])ogee(20, 35);
translate([30, -5])text("ogee(20,35)", size=3);

Download: Thingiverse —birb_chirper by scruss. Local copy: birb_chirper.zip