File size: 3,953 Bytes
f372854
01278d2
 
 
 
f372854
01278d2
f372854
 
 
01278d2
f372854
 
01278d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: Marine Soundscape Analyzer
emoji: 🌊
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.23.3
app_file: app.py
pinned: false
license: mit
short_description: Coral reef acoustic analysis
---

# 🌊 Marine Soundscape Analyzer

A comprehensive acoustic analysis tool for **marine and coral reef hydrophone recordings**.

## Features

Upload any audio file (WAV, MP3, FLAC, OGG, AIFF) and get:

| Tab | Content |
|-----|---------|
| πŸ“Š Waveform | Time-domain signal with amplitude envelope |
| πŸ”Š Spectrograms | Linear, Mel-scale, and Log-frequency spectrograms |
| πŸ“‘ Frequency Analysis + MFCC | Power Spectral Density (Welch), spectral centroid over time, MFCC heatmap |
| 🧬 Acoustic Indices | ACI, BI, NDSI, ADI, RMS β€” all shown as time-series bars |
| πŸ“ Temporal Features | Spectral bandwidth, rolloff, flatness, ZCR, onset detection, MFCC delta |
| πŸ“‹ Report | Full markdown report with all statistics and index interpretations |

## Acoustic Indices

| Index | Reference | What it measures |
|-------|-----------|-----------------|
| **ACI** β€” Acoustic Complexity Index | Pieretti et al. 2011 | Temporal variation in spectral amplitude; higher = more complex soundscape |
| **BI** β€” Bioacoustic Index | Boelman et al. 2007 | Energy in the 2–8 kHz biological band |
| **NDSI** β€” Normalized Difference Soundscape Index | Kasten et al. 2012 | Ratio of biotic (2–11 kHz) to anthropogenic (1–2 kHz) energy |
| **ADI** β€” Acoustic Diversity Index | Villanueva-Rivera et al. 2011 | Shannon diversity across frequency bands above a threshold |
| **Hf** β€” Spectral Entropy | Sueur et al. 2008 | Uniformity of energy across frequencies; 0 = tonal, 1 = white noise |
| **Ht** β€” Temporal Entropy | Sueur et al. 2008 | Uniformity of energy over time; 0 = impulsive, 1 = stationary |
| **H** β€” Total Acoustic Entropy | Sueur et al. 2008 | Combined soundscape heterogeneity (Hf Γ— Ht) |

## Marine Coral Reef Context

| Frequency Band | Range | Typical Sources |
|----------------|-------|-----------------|
| Low | 20 – 1,000 Hz | Fish choruses, breaking waves, vessel traffic |
| Snapping Shrimp | 1 – 5 kHz | *Alpheid* snapping shrimp β€” key reef health indicator |
| High Biotic | 5 – 20 kHz | Small crustaceans, urchins, high-frequency fish sounds |

Snapping shrimp produce a characteristic broadband crackling that can be heard throughout the 1–20 kHz range. Healthy reefs typically show **high ACI, positive NDSI, and elevated energy in the snapping-shrimp band**. Degraded reefs tend to be quieter, with lower ACI and flatter spectra.

## Example Recordings

The app ships with example recordings from the project data folder:

- 🦐 Snapping Shrimp
- πŸ¦€ Ghost Crab: Gastric Mill Stridulation
- πŸ‹ Humpback Whale Song
- 🐟 Red Grouper Vocalization

## Running Locally

```bash
pip install -r requirements.txt
python app.py
```

## Deploying to Hugging Face Spaces

1. Create a new **Gradio** Space on [huggingface.co/spaces](https://huggingface.co/spaces).
2. Upload `app.py` and `requirements.txt` to the Space repository.
3. (Optional) Add audio example files under `data/` in the Space repo β€” the app will auto-detect them.

## References

- Pieretti N., Farina A., Morri D. (2011). A new methodology to infer the singing activity of an avian community: The Acoustic Complexity Index (ACI). *Ecological Indicators*.
- Boelman N.T., et al. (2007). Multi-trophic invasion resistance in Hawaii: bioacoustics, field surveys, and airborne remote sensing. *Ecological Applications*.
- Kasten E.P., et al. (2012). The remote environmental assessment laboratory's acoustic library: An archive for studying soundscape ecology. *Ecological Informatics*.
- Villanueva-Rivera L.J., et al. (2011). A primer of acoustic analysis for landscape ecologists. *Landscape Ecology*.
- Sueur J., Pavoine S., Hamerlynck O., Duvail S. (2008). Rapid acoustic survey for biodiversity appraisal. *PLOS ONE*.