Back to projects

Case study / 08

Echo

Detecting wildlife calls from raw rainforest audio.

Echo is an end-to-end audio classification pipeline for Capuchinbird field recordings. It standardizes raw audio, transforms fixed three-second windows into magnitude spectrograms, trains a compact CNN to recognize call evidence, then scans long recordings and collapses consecutive positive windows into per-file call counts.

  • TensorFlow
  • Keras
  • STFT
  • tensorflow-io
  • Python
16 kHz mono3-second windowsPostprocessed counts

Spectrogram representation

STFT turns each audio window into a two-dimensional magnitude map for the CNN.

Fixed inference contract

Every example becomes 16 kHz mono audio with exactly 48,000 samples.

Precision + recall

Both metrics expose performance on imbalanced call and no-call windows.

Postprocessed counting

Adjacent positive windows collapse before the per-recording count is written.

Pipeline

Inference pathOne fixed signal contract from file to count
01Raw audioWAV labels + MP3 field audio
0216 kHz monodecode · mix · resample
033-second window48,000 samples
04STFT320 frame · 32 step
05Spectrogrammagnitude map
06Small CNNbinary probability
07Sliding inferencefixed windows
08Collapse runsadjacent 1s → one event
09Call countper recording
Signal preparationRepresentation + modelCounting logic

Engineering decisions

DecisionWhyTradeoff
Classify spectrograms instead of raw waveformsA magnitude STFT gives a compact time-frequency image that a small 2D CNN can learn from.Frame length and step become fixed preprocessing choices.
Use one three-second input contractTraining clips and inference windows reach the model with the same 48,000-sample shape.Longer context is discarded and shorter clips require zero-padding.
Collapse consecutive positivesA sustained call can trigger adjacent windows, so runs of positives count once.Non-overlapping windows can still split a call near a boundary.

Under the hood

Preprocessing

  • Decode WAV labels and MP3 field recordings
  • Mix down to mono and resample to 16 kHz
  • Pad or truncate to 48,000 samples
  • STFT: 320-sample frame, 32-sample step

Model

  • Two Conv2D layers with 16 filters
  • Flatten into a 64-unit dense layer
  • Sigmoid output for binary classification
  • Adam + binary cross-entropy

Inference

  • Scan each recording in fixed windows
  • Threshold model scores at 0.99
  • Collapse each consecutive positive run
  • Export one count per recording

Technical deep dives

Deep dive A

Audio becomes a learnable image

Echo converts a three-second waveform into a magnitude spectrogram. Time runs horizontally, frequency vertically, and brighter regions carry more energy for the convolutional filters.

16,000 Hz sample rate320 frame length32 frame step

Deep dive B

Positive windows are not the final count

A call may remain audible across adjacent windows. Grouping consecutive predictions converts each positive run into one event before summing, so six raw positives above become three calls.

final count = positive runs, not positive windows

Verified repository output

252 calls across 61 of 100 recordings

The checked-in results CSV provides the per-recording counts. This is pipeline output from the supplied forest recordings, not a production quality benchmark.

Evaluation boundaries

  • Validation uses one held-out notebook split; there is no cross-validation or formal test set.
  • The notebook evaluates at 0.5 but applies an empirical 0.99 threshold during field inference.
  • Inference windows do not overlap, so boundary-straddling calls may be missed or split.
  • The notebook trains in-session and does not persist a model artifact for repeatable deployment.