japht's picture
Update README.md
3da12d0 verified
|
Raw
History Blame Contribute Delete
5.94 kB
metadata
license: cc-by-4.0
task_categories:
  - audio-classification
tags:
  - bioacoustics
  - spectrograms
  - wildlife
  - citizen-science
  - inaturalist
pretty_name: iNatSpectro Bioacoustics (Dev)
size_categories:
  - n<1K

iNatSpectro Bioacoustics

A community-contributed dataset of bioacoustic spectrograms derived from research-grade iNaturalist audio observations. Contributions are made via the iNatSpectro browser extension, which renders spectrograms directly in the browser and allows users to submit the underlying float data for ML training.

Dataset description

Each entry in this dataset corresponds to one iNaturalist audio observation. The spectrogram was computed in-browser by iNatSpectro and the raw float data submitted alongside observation metadata. Entries may include a strong label (an annotated time/frequency bounding box identifying where a species call occurs) or a weak label (species is known to be present in the audio, but the exact location is not annotated).

The dataset is append-only. Each contribution is stored as a separate JSON file at data/{observation_id}_{unix_timestamp_ms}.json. Consumers should deduplicate on observation_id if they need one entry per observation, or keep all entries for ensemble annotation purposes.

Dataset structure

Each file is a JSON object with the following fields:

Field Type Description
observation_id string iNaturalist observation ID
common_name string | null Common name of the observed species
scientific_name string | null Scientific name
iconic_taxon_name string | null Broad taxonomic group (e.g. "Mammalia")
audio_url string Source audio URL on iNaturalist
sample_rate number Sample rate of the source audio in Hz
duration number Duration of the source audio in seconds
profile string iNatSpectro analysis profile used (e.g. "Bat")
nfft number | null FFT size used
min_freq number Lowest displayed frequency in Hz
max_freq number Highest displayed frequency in Hz
scale_mode string Frequency axis scale: "mel", "log", or "linear"
dyn_min number Normalisation floor in dB
dyn_max number Normalisation ceiling in dB
spec_columns number Number of time columns (always 256)
spec_bins number Number of frequency bins (always 128)
spec_data number[] 32,768 floats — the spectrogram (see below)
annotation object | null Bounding box for the species call (see below)
inat_username string | null Contributor's iNaturalist username (opt-in)
contributed_at string ISO 8601 timestamp of contribution

spec_data layout

spec_data is a flattened 1D array of 32,768 raw FFT magnitude values in dB, stored in column-major order (time × frequency):

  • 256 time columns × 128 frequency bins
  • Index into the array: i = col * 128 + bin
  • Frequency axis: bin 0 = max_freq (highest), bin 127 = min_freq (lowest)
  • Values are on a dB scale. Use dyn_min and dyn_max to normalise to [0, 1] if needed

Reconstruct as a 2D array (Python):

import numpy as np
spec = np.array(entry["spec_data"]).reshape(256, 128)  # shape: (time, freq)

Normalise to [0, 1]:

spec_norm = (spec - entry["dyn_min"]) / (entry["dyn_max"] - entry["dyn_min"])
spec_norm = np.clip(spec_norm, 0, 1)

annotation field

null indicates a weak label — the species is confirmed present somewhere in the audio but the exact location is unknown.

When present, annotation is a strong label giving the time/frequency bounding box of the species call:

{
  "time_start": 1.2,
  "time_end":   2.8,
  "freq_low":   15000,
  "freq_high":  80000
}

All values are in seconds (time) or Hz (frequency).

Source data

Observations are sourced from iNaturalist, a global citizen science platform. Only research-grade observations are eligible for contribution — these have community consensus on species identification.

Audio files remain hosted on iNaturalist and are referenced by audio_url. The spectrogram float data was computed locally in the contributor's browser using iNatSpectro.

How to use

import json
from pathlib import Path
from huggingface_hub import snapshot_download
import numpy as np
# Download the dataset
repo_path = snapshot_download(repo_id="japht/inatspectro-bioacoustics", repo_type="dataset")
entries = []
for f in Path(repo_path, "data").glob("*.json"):
    entries.append(json.loads(f.read_text()))
# Example: load a spectrogram
entry = entries[0]
spec = np.array(entry["spec_data"]).reshape(256, 128)  # (time, freq)
spec_norm = np.clip(
    (spec - entry["dyn_min"]) / (entry["dyn_max"] - entry["dyn_min"]),
    0, 1
)

Deduplicate by observation (keep latest contribution per observation):

from collections import defaultdict
by_obs = defaultdict(list)
for e in entries:
    by_obs[e["observation_id"]].append(e)
deduped = [
    sorted(v, key=lambda x: x["contributed_at"])[-1]
    for v in by_obs.values()
]

Filter to strong labels only:

strong = [e for e in entries if e["annotation"] is not None]

License

This dataset is released under CC BY 4.0. Source audio observations on iNaturalist are subject to their individual observation licenses as set by their authors. Spectrogram float data and metadata in this dataset are contributed under CC BY 4.0 by iNatSpectro users.

Contributing

Contributions are made via the iNatSpectro browser extension. Open any research-grade iNaturalist observation with audio, render the spectrogram, and click Contribute to submit.