Metadata-Version: 2.5
Name: bioamla
Version: 0.5.0
Summary: Bioacoustics & Machine Learning Applications
Project-URL: Homepage, https://github.com/jmcmeen/bioamla
Project-URL: Documentation, https://jmcmeen.github.io/bioamla
Project-URL: Source, https://github.com/jmcmeen/bioamla
Project-URL: Changelog, https://github.com/jmcmeen/bioamla/blob/main/CHANGELOG.md
Project-URL: Bug Tracker, https://github.com/jmcmeen/bioamla/issues
Author-email: John McMeen <johnmcmeen@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.11
Requires-Dist: huggingface-hub
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pyarrow
Requires-Dist: pydantic>=2.7
Requires-Dist: pyinaturalist
Requires-Dist: python-dotenv>=1.0
Requires-Dist: requests>=2.28.0
Requires-Dist: riffy>=0.3.9
Requires-Dist: scipy
Requires-Dist: soundfile
Provides-Extra: all
Requires-Dist: audiomentations; extra == 'all'
Requires-Dist: datasets[audio]; extra == 'all'
Requires-Dist: evaluate; extra == 'all'
Requires-Dist: fastapi>=0.110; extra == 'all'
Requires-Dist: hdbscan>=0.8.0; extra == 'all'
Requires-Dist: librosa; extra == 'all'
Requires-Dist: matplotlib; extra == 'all'
Requires-Dist: mlflow>=2.0; extra == 'all'
Requires-Dist: numba; extra == 'all'
Requires-Dist: scikit-learn>=1.0.0; extra == 'all'
Requires-Dist: sounddevice>=0.4.0; extra == 'all'
Requires-Dist: tensorboard; extra == 'all'
Requires-Dist: torch; extra == 'all'
Requires-Dist: torchaudio; extra == 'all'
Requires-Dist: torchvision; extra == 'all'
Requires-Dist: transformers[torch]>=5.10.2; extra == 'all'
Requires-Dist: umap-learn>=0.5.0; extra == 'all'
Requires-Dist: uvicorn>=0.29; extra == 'all'
Provides-Extra: audio
Requires-Dist: librosa; extra == 'audio'
Requires-Dist: sounddevice>=0.4.0; extra == 'audio'
Provides-Extra: cli
Requires-Dist: click; extra == 'cli'
Requires-Dist: rich; extra == 'cli'
Provides-Extra: cluster
Requires-Dist: hdbscan>=0.8.0; extra == 'cluster'
Requires-Dist: scikit-learn>=1.0.0; extra == 'cluster'
Requires-Dist: umap-learn>=0.5.0; extra == 'cluster'
Provides-Extra: detect
Requires-Dist: librosa; extra == 'detect'
Requires-Dist: sounddevice>=0.4.0; extra == 'detect'
Provides-Extra: dev
Requires-Dist: audiomentations; extra == 'dev'
Requires-Dist: click; extra == 'dev'
Requires-Dist: datasets[audio]; extra == 'dev'
Requires-Dist: evaluate; extra == 'dev'
Requires-Dist: fastapi>=0.110; extra == 'dev'
Requires-Dist: hdbscan>=0.8.0; extra == 'dev'
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: librosa; extra == 'dev'
Requires-Dist: matplotlib; extra == 'dev'
Requires-Dist: mkdocs-click>=0.8; extra == 'dev'
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
Requires-Dist: mkdocs>=1.6; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'dev'
Requires-Dist: mlflow>=2.0; extra == 'dev'
Requires-Dist: numba; extra == 'dev'
Requires-Dist: pymdown-extensions<12,>=11.0.1; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest-xdist; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: rich; extra == 'dev'
Requires-Dist: ruff<0.18,>=0.17; extra == 'dev'
Requires-Dist: scikit-learn>=1.0.0; extra == 'dev'
Requires-Dist: sounddevice>=0.4.0; extra == 'dev'
Requires-Dist: tensorboard; extra == 'dev'
Requires-Dist: torch; extra == 'dev'
Requires-Dist: torchaudio; extra == 'dev'
Requires-Dist: torchvision; extra == 'dev'
Requires-Dist: transformers[torch]>=5.10.2; extra == 'dev'
Requires-Dist: umap-learn>=0.5.0; extra == 'dev'
Requires-Dist: uvicorn>=0.29; extra == 'dev'
Provides-Extra: indices
Requires-Dist: librosa; extra == 'indices'
Requires-Dist: numba; extra == 'indices'
Requires-Dist: sounddevice>=0.4.0; extra == 'indices'
Provides-Extra: ml
Requires-Dist: audiomentations; extra == 'ml'
Requires-Dist: datasets[audio]; extra == 'ml'
Requires-Dist: evaluate; extra == 'ml'
Requires-Dist: librosa; extra == 'ml'
Requires-Dist: mlflow>=2.0; extra == 'ml'
Requires-Dist: scikit-learn>=1.0.0; extra == 'ml'
Requires-Dist: sounddevice>=0.4.0; extra == 'ml'
Requires-Dist: tensorboard; extra == 'ml'
Requires-Dist: torch; extra == 'ml'
Requires-Dist: torchaudio; extra == 'ml'
Requires-Dist: torchvision; extra == 'ml'
Requires-Dist: transformers[torch]>=5.10.2; extra == 'ml'
Provides-Extra: server
Requires-Dist: fastapi>=0.110; extra == 'server'
Requires-Dist: uvicorn>=0.29; extra == 'server'
Provides-Extra: viz
Requires-Dist: librosa; extra == 'viz'
Requires-Dist: matplotlib; extra == 'viz'
Requires-Dist: sounddevice>=0.4.0; extra == 'viz'
Description-Content-Type: text/markdown

# bioamla

[![PyPI version](https://img.shields.io/pypi/v/bioamla.svg)](https://pypi.org/project/bioamla/)
[![Python](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/jmcmeen/bioamla/blob/main/LICENSE)
[![CI](https://github.com/jmcmeen/bioamla/actions/workflows/ci.yml/badge.svg)](https://github.com/jmcmeen/bioamla/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/badge/docs-mkdocs--material-blue.svg)](https://jmcmeen.github.io/bioamla)

A Python library and command-line tool for bioacoustics: audio and recorder metadata,
signal processing, acoustic indices, event detection, spectrograms, species catalogs,
datasets, and Audio Spectrogram Transformer (AST) models. Run it on your laptop, or on a
server next to your recordings.

## Install

Python 3.11 or newer, in a virtual environment:

```bash
pip install "bioamla[all,cli]"     # everything, plus the `bioamla` command
pip install "bioamla[audio,cli]"   # or only the parts you need
pip install bioamla                # the slim library alone: no PyTorch, librosa or plots
```

| Extra | For |
|---|---|
| *(none)* | audio I/O and info, recorder metadata, batch runs, datasets, catalogs |
| `audio` | signal processing (filter, denoise, segment, ...) and playback |
| `viz` | spectrograms, plots and videos |
| `indices` | acoustic indices |
| `detect` | event detection |
| `ml` | AST prediction, training and embeddings (PyTorch) |
| `cluster` | dimensionality reduction and clustering |
| `server` | `bioamla serve` |
| `cli` | the `bioamla` command |
| `all` | every extra but `cli` |

Using a feature whose extra is missing tells you what to install.

### System dependencies

Formats other than WAV, FLAC and OGG, and spectrogram videos, need FFmpeg
(`apt install ffmpeg`, `brew install ffmpeg`, or `conda install -c conda-forge ffmpeg`).
AST prediction can use its shared libraries (versions 4 to 8) to decode audio. Check what
you have with `bioamla system deps`.

## Quickstart

```bash
bioamla audio info recording.wav                  # duration, rate, channels, bit depth
bioamla audio metadata recording.wav              # recorder metadata: when, where, which unit
bioamla audio visualize recording.wav -o spec.png
bioamla indices compute recording.wav             # ACI, ADI, AEI, BIO, NDSI, entropy
bioamla detect energy recording.wav -o detections.csv
bioamla models ast predict frog.wav --model-path bioamla/scp-frogs --top-k 3

# The same over a folder, or a CSV with a file_name column (a copy with the results
# added goes to the output folder):
bioamla batch index --input-dir ./recordings --output-dir ./out
bioamla batch detect energy --input-file recordings.csv --output-dir ./out
```

`bioamla --json <command>` prints one JSON document, for scripts and agents. Every
command has `--help`, and the [CLI reference](https://jmcmeen.github.io/bioamla/cli/)
lists them all.

Everything the command does, the library does too:

```python
from bioamla.audio import load_audio_data
from bioamla.indices import compute_all_indices
from bioamla.ml import classify_file

audio = load_audio_data("recording.wav")
print(compute_all_indices(audio.samples, audio.sample_rate).aci)
print(classify_file("frog.wav", model_path="bioamla/scp-frogs").predictions[0].predicted_label)
```

Errors raise `bioamla.exceptions.BioamlaError` (or a subclass).

## Workspaces

A workspace is a project folder that remembers its recordings, settings and history:

```bash
bioamla workspace init costa-rica && cd costa-rica
bioamla workspace add /data/recordings/site1      # link recordings where they are
bioamla workspace config set detect.energy.threshold_db -25
bioamla workspace history                          # what ran, when, and what it wrote
```

## Working on a server

Run bioamla on the machine that holds the recordings (or the GPU), and drive it from
your laptop with the same commands:

```bash
# On the server (it listens on localhost only)
pip install "bioamla[all,cli]"
bioamla serve --root ~/bioamla-workspaces --allow-link /data/recordings

# On the laptop: reach it through an SSH tunnel, then add it as a remote
ssh -N -L 8765:localhost:8765 lab-server &
bioamla remote add lab http://localhost:8765
export BIOAMLA_LAB_TOKEN=...                       # from the server's token file
bioamla remote workspaces lab --create costa-rica
bioamla remote upload lab costa-rica rec.wav --to raw
bioamla --remote lab:costa-rica detect energy raw/rec.wav
```

The output is the same as a local run's. See
[Running the server](https://jmcmeen.github.io/bioamla/server/) for the token, a VPN
instead of a tunnel, and systemd.

## Agent skills

[`skills/`](https://github.com/jmcmeen/bioamla/tree/main/skills) has skills that let an
AI agent drive bioamla, locally or on a server: `inventory` describes a folder of
recordings, `label` does a first pass of labeling, sending anything uncertain to a
person, `label-qa` checks an annotation set and gives a pass/fail verdict, `dataset`
builds a dataset and publishes it only once its licenses, locations and splits pass, and
`train` fine-tunes a model and keeps it only if it beats a baseline on a fixed evaluation
set. In
Claude Code, install them with `/plugin install bioamla --marketplace jmcmeen/bioamla`.
See [Agent skills](https://jmcmeen.github.io/bioamla/skills/).

## API keys

The catalog commands read `EBIRD_API_KEY`, `XC_API_KEY` (Xeno-canto) and `HF_TOKEN`
(Hugging Face) from the environment, or from a `.env` file in the working directory or a
parent (only those three keys, and an exported variable wins). Nothing else needs a key.

## More

- Documentation: the [CLI reference](https://jmcmeen.github.io/bioamla/cli/),
  [using the library](https://jmcmeen.github.io/bioamla/library/) and its
  [API reference](https://jmcmeen.github.io/bioamla/api/audio/),
  [settings](https://jmcmeen.github.io/bioamla/settings/) and
  [recorder metadata](https://jmcmeen.github.io/bioamla/recorder-metadata/).
- [Examples](https://github.com/jmcmeen/bioamla/tree/main/examples): end-to-end scripts,
  from catalog downloads to a trained and published model.
- [Contributing](https://github.com/jmcmeen/bioamla/blob/main/CONTRIBUTING.md),
  [Code of Conduct](https://github.com/jmcmeen/bioamla/blob/main/CODE_OF_CONDUCT.md),
  [Security Policy](https://github.com/jmcmeen/bioamla/blob/main/SECURITY.md).

## Citation

If you use bioamla in research, please cite the Zenodo DOI of the version you used, or
use GitHub's "Cite this repository" button
([`CITATION.cff`](https://github.com/jmcmeen/bioamla/blob/main/CITATION.cff)):

```bibtex
@software{mcmeen_bioamla,
  author  = {McMeen, John},
  title   = {bioamla: Bioacoustics \& Machine Learning Applications},
  year    = {2026},
  license = {MIT},
  url     = {https://github.com/jmcmeen/bioamla}
}
```

## License

MIT. See [LICENSE](https://github.com/jmcmeen/bioamla/blob/main/LICENSE).
