A month with AudioMoth

In my personal time over the past few months, I've worked on a lot of code to connect machine learning models to various conservation, species-detection problems.  A bunch of this work has focused on automating species detection in camera trap videos, both terrestrial and aquatic.  I'll write about that work in another post at some point, but today I wanted to talk about a related project: automatic species detection for birds using audio recordings done with an AudioMoth.

AudioMoths are small, relatively inexpensive acoustic loggers used by bird, bat, and other biologists, ecologists, and people like me, to monitor wildlife species based on sound.  Imagine a device, smaller than a deck of playing cards, with a built-in microphone, SD storage card, and microprocessor that can be programmed to record audio on a specific schedule.  

AudioMoth
AudioMoth (without case)

Our family has spent years working with camera traps, which are great for collecting photos or videos (we prefer video) of wildlife based on movement.  The camera traps we use do record some audio, but it's poor quality.  I really wanted to see how much better I could do with an audio-only device like the AudioMoth.  I've loved using Merlin Bird ID to do bird species detection on my phone, and I wanted to see if I could do this kind of monitoring long-term in an environment.

Unfortunately (for me), AudioMoths are very popular with researchers, and can be hard to acquire.  Last winter I started stalking the site where you can buy them in North America.  You have to wait for them to have enough backers to build a new run of these units.  Eventually in early summer, I was able to buy one and it shipped at the end of August.

I spent a number of days learning how to use it.  You need 3 AA batteries, a micro-SD card, and a cable to connect to it via USB.  There is an open source app that lets you create a config file, defining your recording settings, schedule, etc.

AudioMoth USB Connection
Programming the AudioMoth

I also opted to buy a waterproof case, which comes with a velcro strap you can use to attach the unit to a tree limb.  After this you mount it wherever you want to do your recording.

AudioMoth Waterproof Case

It took me the better part of a week to figure out the right settings to use (I'm still not 100% sure what I'm doing is optimal).  I've found the AudioMoth to be a bit more like a research tool vs. a commercial product, in terms of its ease of use for an amateur/enthusiast like me.  However, I'm used to learning-as-I-go with technology, and if you're willing to tinker and experiment, you can get good results.

Once I was satisfied that my recordings were working, I moved the device into a better spot to try a longer experiment.  I picked an area where a number of different ecosystems meet: mixed deciduous forest, scrub brush, swamp wetland, edge of a creek, etc.  This is usually a great birding spot, and also unlikely to cause issues with recording human activity (too early, too buggy, too dense):

AudioMoth Location at intersection of different habitats

My goal was to record the bird chorus for 2 hours every morning (5:30 am - 7:30 am) for the month of September.  I wanted to collect this data in order to understand which species were moving through our woods during fall migration.

Yesterday I went to collect my data.  However, when I got there, the AudioMoth was gone!  Something (raccoon, likely) had undone the velcro strap and it was laying in the long grass beneath the tree.  I'm going to need a better mounting option!

After downloading all the .wav audio files from the SD card, I wrote a bunch of Python code to use BirdNet as my species detection algorithm.  BirdNet can detect ~6,000 species, and uses latitude and longitude, as well as historic sighting data from eBird to determine likely species lists for a given location/period.

My code uses the open source BirdNet-Analyzer via birdnetlib, both of which are amazing.  I was able to very quickly go from concept to working code in a matter of hours.  The BirdNet lib is able to extract data and audio recordings for each detection.  For example, you might get a detection like this, along with a 3 second .mp3 file:

{
	"common_name": "Common Yellowthroat",
	"scientific_name": "Geothlypis trichas",
	"start_time": 3207.0,
	"end_time": 3210.0,
	"confidence": 0.732090950012207,
	"extracted_audio_path": "20230831_053000_3206s-3210s.mp3"
}

This is amazing!  However, coming from a "camera trap" background, I really wanted to have something larger than a single clip.  I decided to analyze all of the detections to find the top 10 by confidence (i.e., how confident is the model about the species) for each species, then use that to create a kind of "greatest hits" sample that combines each individual detection one-after-another.

This produced fantastic results, making it so much easier to compare audio for a species to other recordings, even those that occurred on different days.  Having multiple samples to listen to back-to-back also helped get a better sense of the range of what each species sounds like.

I did some more analysis on the data to get a complete list of the 39 species for the month:

- American Crow
- Yellow-rumped Warbler
- Common Yellowthroat
- White-breasted Nuthatch
- Black-capped Chickadee
- Cedar Waxwing
- Common Grackle
- Blue Jay
- Downy Woodpecker
- American Goldfinch
- Swamp Sparrow
- White-throated Sparrow
- Eastern Bluebird
- Pileated Woodpecker
- Ruby-throated Hummingbird
- Hairy Woodpecker
- Gray Catbird
- Golden-crowned Kinglet
- Song Sparrow
- American Robin
- Eastern Phoebe
- Killdeer
- Eastern Kingbird
- Canada Goose
- Northern Flicker
- Barn Swallow
- Swainson's Thrush
- House Finch
- Rose-breasted Grosbeak
- Yellow Warbler
- Magnolia Warbler
- Blackpoll Warbler
- White-crowned Sparrow
- Common Loon*
- Savannah Sparrow
- Chestnut-sided Warbler
- Greater Yellowlegs
- Lesser Yellowlegs
- Ruby-crowned Kinglet
- Red-bellied Woodpecker

I've been able to confirm most of these manually (to the best of my ability), however, the Common Loon detections are for sure not right (the recordings were of coyotes howling).  I'll need to tweak my parameters to the AI model.

Here's a graph of all the species and how many days each one was detected, giving a sense of frequency across the month. I was surprised that the Yellowthroats were the most numerous.

Overall, I'm really impressed.  This was my first major test of the setup and my software, and other than nearly losing the AudioMoth in the swamp, everything worked great.

My next goal is to build a web-based explorer for the data.  For example, I don't have a great way to share the audio files and I'd love to pull in open licensed images of each bird species to build a multi-media experience that makes this data more accessible to others.  Thinking about this, it strikes me that it would be cool to build a bird-species visualization toolkit, since so much of what I need (open licensed images, audio, video, text) would also be needed by anyone else who wants to work on bird web apps.  Maybe I'll find that this already exists, which would be great.

In the meantime, if you're interested in wildlife audio recording, I'd recommend picking up an AudioMoth and doing your own experiments.  With very little knowledge, equipment, or code, I was able to start answering some interesting questions about my own local ecosystems.

Show Comments