Ptree: Interactive Tree of Life Explorer Blog & articles

Blog · Data · · 4 min read

Selecting wildlife recordings without voice notes or silence

Clicking the audio icon on a species or clade in Ptree should play that organism within half a second. It should not play twelve seconds of rustling microphone fabric, an inaudible 250 kHz bat-detector file, or a hiker saying "here is a nice woodlouse on a log." Combining xeno-canto and iNaturalist into one recording per species required solving three separate problems: deciding which clades actually make sound, measuring the audio files directly, and filtering out human speech.

Filtering out silent clades with a rate gate

xeno-canto is a curated archive of animal sounds, so its records start from vocal organisms. iNaturalist lets any observer attach an audio clip to any observation. As a result, plants, fungi, rocks, and silent beetles accumulate accidental clips, wind, background birds, and spoken field notes at a steady background rate.

Research grade, faves, and organism annotations do not separate real animal sounds from voice notes, because the community usually confirms the species from an attached photograph. Instead, Ptree checks how often each clade is recorded compared with the rest of life:

  • Across all iNaturalist orders that have at least 100,000 observations, Ptree computes the median rate of distinct recordists per observation. That median sits around one recordist per 300,000 observations and acts as the background noise floor.
  • A clade passes the gate only when at least 3 distinct people have recorded it, its recording rate is at least 10 times the background floor, and the Poisson probability of seeing that many recordists by chance is below 0.001.
  • For any taxon, Ptree finds the nearest ancestor large enough that a 10× lift would produce at least 5 expected recordists, and lets that ancestor render the verdict. A smaller clade beneath it can still qualify on its own if it clears the threshold.

That last rule lets genuine vocal outliers, such as rattlebox grasshoppers or drum fishes, pass even when their larger family or order is mostly silent. At the same time, it rejects stray voice notes attached to woodlice, ants, and wildflowers.

On top of the clade gate, the iNaturalist reader drops observations that have lost research grade since the archive was cut, observations whose description starts with voice notes, and recordings on the explicit exclusion list.

Measuring loudness, onset, clipping, and ultrasonic energy

Metadata decides which candidates to fetch, but acoustic measurement picks the winner among a species' recordings. Every fetched candidate is analyzed into a local acoustics store that keeps a momentary loudness reading every tenth of a second, along with peak level, noise floor, spectral flatness, five frequency bands, and file size.

From the momentary loudness series, Ptree locates the exact moment when the animal starts calling:

const call = readings.toSorted((a, b) => a - b)[Math.floor((readings.length - 1) * 0.95)];
const line = Math.max(-45, call - 12);

The animal's call level is the 95th percentile of those readings. Any tenth-second slice that sits within 12 dB of that level and above −45 dB counts as the animal. After skipping the loudness meter's first three readings (where its 400 ms window is still filling), the first matching slice sets the recording's onset. A steady frog chorus or cricket trill is loud from end to end and gets an onset near zero. A bird that sits silent for nine seconds before singing gets onset = 9.0, and the player jumps straight to that second with a #t= media fragment so the visitor hears the bird right away.

Any recording whose measured peak is -Infinity is rejected outright. That catches phone recordings that wrote ten seconds of digital zeros because microphone permission was withheld. The remaining measured candidates are scored as a sum of named terms:

  • signal: loudest ten seconds over the noise floor, neutral at 20 dB and earning up to +1 at 40 dB.
  • clipping: -1 when the peak exceeds -0.3 dB with a non-zero flat factor.
  • audibility: -2 when energy above 20 kHz dominates every audible band, catching ultrasonic bat-detector files alongside a -2 penalty on xeno-canto sample rates of 176.4 kHz or higher.
  • hiss and silence: -0.5 when spectral flatness exceeds 0.35, and -0.5 when more than half of the file sits below the animal threshold.
  • onset and size: late onsets past 0.5 seconds lose up to -1 by five seconds, and every 5 MB of file size costs -0.5 so visitors do not have to buffer huge uncompressed WAV files when a clean MP3 exists.

Catching narration with YAMNet

A recordist who talks over a bird call often produces great signal-to-noise, low hiss, and an immediate onset. Every loudness metric rewards a clear human voice. To catch narration, background conversation, and tour guides talking near the microphone, Ptree runs Google's YAMNet classifier at 16 kHz mono (using 0.96-second windows with a 0.48-second hop). All 521 AudioSet class scores are quantized to 1 byte (255 * score) alongside half-float features, then Zstd-compressed in the acoustics store.

At build time, Ptree decompresses each recording's score matrix on the fly and checks eight speech classes (Speech, Child speech, Conversation, Narration, monologue, Babbling, Speech synthesizer, Whispering, and Hubbub, speech noise). If 3 or more frames anywhere in the file hit a speech score of 0.5 (>= 128) or higher, the recording is marked spoken and demoted. It plays only when the species has no unspoken recording at all.

Matching higher-clade audio to the photo you see

Rolling sounds up the tree raises one last surprise. If a family card displays a photograph of a blue jay, playing the highest-scoring recording from a random crow elsewhere in Corvidae feels wrong. While the sound rollup folds the best recording across every clade's subtree, the audio endpoint checks first whether the species shown in the clade's photo or silhouette has a decent recording. When it does, pressing play lets you hear the exact animal that you are looking at.