Skip to main content

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:

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monkeycall-0.0.3.dev0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

monkeycall-0.0.3.dev0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file monkeycall-0.0.3.dev0.tar.gz.

File metadata

  • Download URL: monkeycall-0.0.3.dev0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for monkeycall-0.0.3.dev0.tar.gz
Algorithm Hash digest
SHA256 8e408a20caed4480b2946765738c8c9334af3bbc7d9941fe6773aa958b28d188
MD5 cf9da2a6ad99d4afd2c177df60c27f65
BLAKE2b-256 ef75be537b8cb58ea68d165466fcd61dd8dbdfa4e778347b21e9f34509921532

See more details on using hashes here.

File details

Details for the file monkeycall-0.0.3.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for monkeycall-0.0.3.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 d861fdb802627903ce3b345132c47e93ff31b72619c50416bf1614453c2fc036
MD5 131807256cb12dcf4cd6485838acb84f
BLAKE2b-256 80473f6825e0a046f29e3f23046a38d4b0343f0984c34a6350136bf603a61af4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page