Detect (spider/howler) monkey calls using pretrained TF2 models from Hugging Face.
Project description
Monkey Call Detector
Detect spider monkey whinny calls (and howler monkey calls) in audio recordings using pre-trained TensorFlow models.
This package downloads a model from 🤗 Hugging Face and provides simple functions for ecologists and data scientists to run inference on short clips or entire recordings.
Installation
This has been tested with a fresh python 3.13 installation.
(Optional) Make a virtual environment (python -m venv /path/to/new/virtual/environment)
pip3 install monkeycall # This will also install requirements.
Usage examples
You can now detect monkey calls. To detect spider monkeys try the following:
Detecting the Spider Monkey whinny
from monkeycall.spider_monkey import load_model, predict_recording
recording_path = "/path/to/sample.WAV"
repo_id = "georgiosrizos/spider-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Reading long recording:", recording_path)
output_df = predict_recording(audio_path=recording_path,
model=model,
hop_size=1)
print("The recording has been clipped in 3 sec window clips. The whinny detection probabilities are:", output_df)
# You can save the pandas DataFrame to review later.
output_df.to_csv("predictions.csv", index=False)
Or if you already have a 3 sec clip:
from monkeycall.spider_monkey import load_model, predict_3_sec_clip
recording_path = "/path/to/3sec.WAV"
repo_id = "georgiosrizos/spider-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Reading clip:", negative)
output = predict_3_sec_clip(audio_path=recording_path,
model=model)
print("The probability this sample contains a whinny is:", output)
If you have a folder containing multiple audio files, you can run the following:
from monkeycall.spider_monkey import load_model, predict_recording
input_folder = "/path/to/audio/file/folder"
output_folder = "/path/to/store/positive/clips/folder"
repo_id = "georgiosrizos/spider-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Search folder for calls:", long_recording_folder)
output_df = search_folder_for_calls(input_folder=long_recording_folder,
model=inference_fn,
hop_size=1,
probability_threshold=0.5,
output_folder=output_folder,
extensions=(".wav", ".mp3", ".flac", ".ogg"))
print("The recordings have been clipped in 3 sec window clips. The whinny detection probabilities are:", output_df)
# You can save the pandas DataFrame to review later.
output_df.to_csv("predictions.csv", index=False)
Detecting the Howler Monkey hoot and roar
from monkeycall.howler_monkey import load_model, predict_recording
recording_path = "/path/to/sample.WAV"
repo_id = "georgiosrizos/howler-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Reading long recording:", recording_path)
output_df = predict_recording(audio_path=recording_path,
model=model,
hop_size=2)
print("The recording has been clipped in 5 sec window clips. The hoot and roar detection probabilities are:", output_df)
# You can save the pandas DataFrame to review later.
output_df.to_csv("predictions.csv", index=False)
Or if you already have a 5 sec clip:
from monkeycall.howler_monkey import load_model, predict_5_sec_clip
recording_path = "/path/to/5sec.WAV"
repo_id = "georgiosrizos/howler-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Reading clip:", negative)
output = predict_5_sec_clip(audio_path=recording_path,
model=model)
print("The probability this sample contains a hoot is:", output[0])
print("The probability this sample contains a roar is:", output[1])
If you have a folder containing multiple audio files, you can run the following:
from monkeycall.howler_monkey import load_model, predict_recording
input_folder = "/path/to/audio/file/folder"
output_folder = "/path/to/store/positive/clips/folder"
repo_id = "georgiosrizos/howler-monkey-detector-SEResNet"
print("Reading pre-trained model.")
model = load_model(architecture=repo_id)
print("Search folder for calls:", long_recording_folder)
output_df = search_folder_for_calls(input_folder=long_recording_folder,
model=inference_fn,
hop_size=2,
probability_threshold=0.5,
output_folder=output_folder,
extensions=(".wav", ".mp3", ".flac", ".ogg"))
print("The recordings have been clipped in 5 sec window clips. The hoot and roar detection probabilities are:", output_df)
# You can save the pandas DataFrame to review later.
output_df.to_csv("predictions.csv", index=False)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file monkeycall-0.0.4.tar.gz.
File metadata
- Download URL: monkeycall-0.0.4.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95d95f66984ebac0408191ab138e4d0174e9c384a8e373c8da6fd42c0d3bbcbb
|
|
| MD5 |
6351415e2d2c585a289bcdaf757b4683
|
|
| BLAKE2b-256 |
2f49e66f058f36da0dc0d22773cfd3339879c5917fe189068f65fc56e5d3d5df
|
File details
Details for the file monkeycall-0.0.4-py3-none-any.whl.
File metadata
- Download URL: monkeycall-0.0.4-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bebfd91ea3a85549805177d84d90807de2dd985343831cd2309e8ff1d3cac31
|
|
| MD5 |
109d87ee5579dbe78a3b6ec2b163d380
|
|
| BLAKE2b-256 |
ffad96788797dcdaff2891f81e4fc9e9a0711cd2bc0a1a24fd2528505cb3a9f7
|