Skip to main content

A python api for BirdNET-Lite and BirdNET-Analyzer

Project description

birdnetlib

PyPI Test

A python api for BirdNET-Lite and BirdNET-Analyzer

Installation

birdnetlib requires Python 3.7+ and prior installation of Tensorflow Lite, librosa and ffmpeg. See BirdNET-Analyzer for more details on installing the Tensorflow-related dependencies.

pip install birdnetlib

Documentation

birdnetlib provides a common interface for BirdNET-Lite and BirdNET-Analyzer.

Using BirdNET-Lite

To use the BirdNET-Lite model, use the LiteAnalyzer class.

from birdnetlib import Recording
from birdnetlib.analyzer_lite import LiteAnalyzer

# Load and initialize the BirdNET-Lite models.
analyzer = LiteAnalyzer()

recording = Recording(
    analyzer,
    "sample.mp3",
    lat=35.4244,
    lon=-120.7463,
    week=18,
    min_conf=0.25,
)
recording.analyze()
print(recording.detections) # Returns list of detections.

recording.detections contains a list of detected species, along with time ranges and confidence value.

[{'common_name': 'House Finch',
  'confidence': 0.5744,
  'end_time': 12.0,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 9.0},
 {'common_name': 'House Finch',
  'confidence': 0.4496,
  'end_time': 15.0,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 12.0}]

Using BirdNET-Analyzer

To use the newer BirdNET-Analyzer model, use the Analyzer class.

from birdnetlib import Recording
from birdnetlib.analyzer import Analyzer

# Load and initialize the BirdNET-Analyzer models.
analyzer = Analyzer()

recording = Recording(
    analyzer,
    "sample.mp3",
    lat=35.4244,
    lon=-120.7463,
    week=18,
    min_conf=0.25,
)
recording.analyze()
print(recording.detections)

Other common helper classes

DirectoryWatcher

DirectoryWatcher can watch a directory and analyze new files as they are created.

def on_analyze_complete(recording):
    print(recording.path)
    pprint(recording.detections)

watcher = DirectoryWatcher("/Birds/mp3_dir")
watcher.on_analyze_complete = on_analyze_complete
watcher.watch()

See the full example for analyzer options and error handling callbacks.

About BirdNET-Lite and BirdNET-Analyzer

birdnetlib uses models provided by BirdNET-Lite and BirdNET-Analyzer under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License.

BirdNET-Lite and BirdNET-Analyzer were developed by the K. Lisa Yang Center for Conservation Bioacoustics at the Cornell Lab of Ornithology.

For more information on BirdNET analyzers, please see the project repositories below:

BirdNET-Analyzer

BirdNET-Lite

birdnetlib is not associated with BirdNET-Lite, BirdNET-Analyzer or the K. Lisa Yang Center for Conservation Bioacoustics.

About birdnetlib

birdnetlib is maintained by Joe Weiss.

Project Goals

  • Establish a unified API for interacting with Tensorflow-based BirdNET analyzers
  • Enable python-based test cases for BirdNET analyzers
  • Make it easier to use BirdNET in python-based projects
  • Make it easier to migrate to new BirdNET versions/models as they become available

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

birdnetlib-0.0.9.tar.gz (88.4 MB view details)

Uploaded Source

Built Distribution

birdnetlib-0.0.9-py3-none-any.whl (88.4 MB view details)

Uploaded Python 3

File details

Details for the file birdnetlib-0.0.9.tar.gz.

File metadata

  • Download URL: birdnetlib-0.0.9.tar.gz
  • Upload date:
  • Size: 88.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for birdnetlib-0.0.9.tar.gz
Algorithm Hash digest
SHA256 bdc18c202c451ac2b4b38a124870b427d32e7511f6610dadf8d18ef2da7294d1
MD5 49c4d7d2723a0778be28f9c4522239e6
BLAKE2b-256 9b75fd345facca54545758277840ff85352b9ce92a8e6050f9b218adeede4abb

See more details on using hashes here.

File details

Details for the file birdnetlib-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: birdnetlib-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 88.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for birdnetlib-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2aa22c384132f0d5e63475d68ee39304d1a8a72c7de77dd627b7bd2442dd0bd7
MD5 c862319a93a7bbcc9e78c5a8ebc909bc
BLAKE2b-256 3c5605fc388409ea136af0e3418330cbf240709c49cec0cf5d3fc3be4e8bb4f5

See more details on using hashes here.

Supported by

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