An API for model loading and inference, and a Python-based system for training and evaluating bioacoustics representation learning models.
The Animal Vocalization Encoder library AVEX provides a unified interface for working with pre-trained bioacoustics representation learning models, with support for:
requires-python in pyproject.toml; CI runs 3.13 on Ubuntu)pip install avex
uv add avex
For development installation with training/evaluation tools, see the Contributing guide.
import torch
import librosa
from avex import load_model, list_models
# List available models
print(list_models().keys())
# Load a pre-trained model
model = load_model("esp_aves2_sl_beats_all", device="cpu")
# Load and preprocess audio (BEATs expects 16kHz)
audio, sr = librosa.load("your_audio.wav", sr=16000)
audio_tensor = torch.tensor(audio).unsqueeze(0) # Shape: (1, num_samples)
# Run inference
with torch.no_grad():
logits = model(audio_tensor)
predicted_class = logits.argmax(dim=-1).item()
# Get human-readable label
if model.label_mapping:
label = model.label_mapping.get(str(predicted_class), predicted_class)
print(f"Predicted: {label}")
# Load for embedding extraction (no classifier head)
model = load_model("esp_aves2_sl_beats_all", return_features_only=True, device="cpu")
with torch.no_grad():
embeddings = model(audio_tensor)
# Shape: (batch, time_steps, 768) for BEATs
# Pool to get fixed-size embedding
embedding = embeddings.mean(dim=1) # Shape: (batch, 768)
For some analyses and probes it can help to extract embeddings from multiple internal layers. You can select layers by index (0-based, negative indices allowed) instead of long module names.
import torch
from avex import load_model
model = load_model("esp_aves2_naturelm_audio_v1_beats", device="cpu")
print(model.get_model_layer_map()) # {0: "...", 1: "...", ...}
audio = torch.randn(1, 16000 * 5)
_ = model.register_hooks_for_layers([0, -1])
emb = model.extract_embeddings(audio, aggregation="mean")
from avex.models.probes import build_probe_from_config
from avex.configs import ProbeConfig
# Load backbone for feature extraction
base = load_model("esp_aves2_sl_beats_all", return_features_only=True, device="cpu")
# Define a probe head for your task
probe_config = ProbeConfig(
probe_type="linear",
target_layers=["last_layer"],
aggregation="mean",
freeze_backbone=True,
online_training=True,
)
probe = build_probe_from_config(
probe_config=probe_config,
base_model=base,
num_classes=10, # Your number of classes
device="cpu",
)
Full documentation: docs/index.md
Examples: See the examples/ directory:
00_quick_start.py - Basic model loading01_basic_model_loading.py - Loading models with different configurations02_checkpoint_loading.py - Working with checkpoints03_custom_model_registration.py - Custom model registration04_training_and_evaluation.py - Training and evaluation examples05_embedding_extraction.py - Feature extraction06_classifier_head_loading.py - Classifier head behaviorThe framework supports the following audio representation learning models:
pip install 'avex[tensorflow]'pip install 'avex[tensorflow]'See Supported Models for detailed information and configuration examples.
The framework provides flexible probe heads for transfer learning:
Probes can be trained:
See Probe System and API Probes for detailed documentation.
If you use this framework in your research, please cite:
@inproceedings{miron2025matters,
title={What Matters for Bioacoustic Encoding},
author={Miron, Marius and Robinson, David and Alizadeh, Milad and Gilsenan-McMahon, Ellen and Narula, Gagan and Chemla, Emmanuel and Cusimano, Maddie and Effenberger, Felix and Hagiwara, Masato and Hoffman, Benjamin and Keen, Sara and Kim, Diane and Lawton, Jane K. and Liu, Jen-Yu and Raskin, Aza and Pietquin, Olivier and Geist, Matthieu},
booktitle={The Fourteen International Conference on Learning Representations},
year={2026}
}
Related ESP papers:
@inproceedings{miron2026probing,
title={Multi-layer attentive probing improves transfer of audio representations for bioacoustics},
author={Miron, Marius and Robinson, David and Hagiwara, Masato and Titouan, Parcollet and Cauzinille, Jules and and Narula, Gagan and Alizadeh, Milad and Gilsenan-McMahon, Ellen and Keen, Sara and Chemla, Emmanuel and Hoffman, Benjamin and Cusimano, Maddie and Kim, Diane and Effenberger, Felix and Lawton, Jane K. and Raskin, Aza and Pietquin, Olivier and Geist, Matthieu},
booktitle={ICASSP 2026-2026 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={1--5},
year={2026},
organization={IEEE}
}
@inproceedings{hagiwara2023aves,
title={Aves: Animal vocalization encoder based on self-supervision},
author={Hagiwara, Masato},
booktitle={ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={1--5},
year={2023},
organization={IEEE}
}
We welcome contributions! Please see CONTRIBUTING.md for:
This project is licensed under the MIT License - see the LICENSE file for details.
An API for model loading and inference, and a Python-based system for training and evaluating bioacoustics representation learning models.
The Animal Vocalization Encoder library AVEX provides a unified interface for working with pre-trained bioacoustics representation learning models, with support for:
requires-python in pyproject.toml; CI runs 3.13 on Ubuntu)pip install avex
uv add avex
For development installation with training/evaluation tools, see the Contributing guide.
import torch
import librosa
from avex import load_model, list_models
# List available models
print(list_models().keys())
# Load a pre-trained model
model = load_model("esp_aves2_sl_beats_all", device="cpu")
# Load and preprocess audio (BEATs expects 16kHz)
audio, sr = librosa.load("your_audio.wav", sr=16000)
audio_tensor = torch.tensor(audio).unsqueeze(0) # Shape: (1, num_samples)
# Run inference
with torch.no_grad():
logits = model(audio_tensor)
predicted_class = logits.argmax(dim=-1).item()
# Get human-readable label
if model.label_mapping:
label = model.label_mapping.get(str(predicted_class), predicted_class)
print(f"Predicted: {label}")
# Load for embedding extraction (no classifier head)
model = load_model("esp_aves2_sl_beats_all", return_features_only=True, device="cpu")
with torch.no_grad():
embeddings = model(audio_tensor)
# Shape: (batch, time_steps, 768) for BEATs
# Pool to get fixed-size embedding
embedding = embeddings.mean(dim=1) # Shape: (batch, 768)
For some analyses and probes it can help to extract embeddings from multiple internal layers. You can select layers by index (0-based, negative indices allowed) instead of long module names.
import torch
from avex import load_model
model = load_model("esp_aves2_naturelm_audio_v1_beats", device="cpu")
print(model.get_model_layer_map()) # {0: "...", 1: "...", ...}
audio = torch.randn(1, 16000 * 5)
_ = model.register_hooks_for_layers([0, -1])
emb = model.extract_embeddings(audio, aggregation="mean")
from avex.models.probes import build_probe_from_config
from avex.configs import ProbeConfig
# Load backbone for feature extraction
base = load_model("esp_aves2_sl_beats_all", return_features_only=True, device="cpu")
# Define a probe head for your task
probe_config = ProbeConfig(
probe_type="linear",
target_layers=["last_layer"],
aggregation="mean",
freeze_backbone=True,
online_training=True,
)
probe = build_probe_from_config(
probe_config=probe_config,
base_model=base,
num_classes=10, # Your number of classes
device="cpu",
)
Full documentation: docs/index.md
Examples: See the examples/ directory:
00_quick_start.py - Basic model loading01_basic_model_loading.py - Loading models with different configurations02_checkpoint_loading.py - Working with checkpoints03_custom_model_registration.py - Custom model registration04_training_and_evaluation.py - Training and evaluation examples05_embedding_extraction.py - Feature extraction06_classifier_head_loading.py - Classifier head behaviorThe framework supports the following audio representation learning models:
pip install 'avex[tensorflow]'pip install 'avex[tensorflow]'See Supported Models for detailed information and configuration examples.
The framework provides flexible probe heads for transfer learning:
Probes can be trained:
See Probe System and API Probes for detailed documentation.
If you use this framework in your research, please cite:
@inproceedings{miron2025matters,
title={What Matters for Bioacoustic Encoding},
author={Miron, Marius and Robinson, David and Alizadeh, Milad and Gilsenan-McMahon, Ellen and Narula, Gagan and Chemla, Emmanuel and Cusimano, Maddie and Effenberger, Felix and Hagiwara, Masato and Hoffman, Benjamin and Keen, Sara and Kim, Diane and Lawton, Jane K. and Liu, Jen-Yu and Raskin, Aza and Pietquin, Olivier and Geist, Matthieu},
booktitle={The Fourteen International Conference on Learning Representations},
year={2026}
}
Related ESP papers:
@inproceedings{miron2026probing,
title={Multi-layer attentive probing improves transfer of audio representations for bioacoustics},
author={Miron, Marius and Robinson, David and Hagiwara, Masato and Titouan, Parcollet and Cauzinille, Jules and and Narula, Gagan and Alizadeh, Milad and Gilsenan-McMahon, Ellen and Keen, Sara and Chemla, Emmanuel and Hoffman, Benjamin and Cusimano, Maddie and Kim, Diane and Effenberger, Felix and Lawton, Jane K. and Raskin, Aza and Pietquin, Olivier and Geist, Matthieu},
booktitle={ICASSP 2026-2026 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={1--5},
year={2026},
organization={IEEE}
}
@inproceedings{hagiwara2023aves,
title={Aves: Animal vocalization encoder based on self-supervision},
author={Hagiwara, Masato},
booktitle={ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={1--5},
year={2023},
organization={IEEE}
}
We welcome contributions! Please see CONTRIBUTING.md for:
This project is licensed under the MIT License - see the LICENSE file for details.
21 followers · starred Mar 2026