### Example detection output Source: https://joeweiss.github.io/birdnetlib/api Sample output structure when return_all_detections is enabled. ```json [{'common_name': 'Spotted Crake', 'confidence': 0.7721, 'end_time': 12.0, 'scientific_name': 'Porzana porzana', 'start_time': 9.0, 'is_predicted_for_location_and_date': False, 'label': 'Haemorhous mexicanus_House Finch'}, {'common_name': 'House Finch', 'confidence': 0.4496, 'end_time': 15.0, 'scientific_name': 'Haemorhous mexicanus', 'start_time': 12.0, 'is_predicted_for_location_and_date': True, 'label': 'Haemorhous mexicanus_House Finch'}] ``` -------------------------------- ### Install birdnetlib Source: https://joeweiss.github.io/birdnetlib/getting-started Install the package using pip. Ensure Python 3.9+ and dependencies like Tensorflow Lite, librosa, and ffmpeg are installed first. ```bash pip install birdnetlib ``` -------------------------------- ### Install birdnetlib Source: https://joeweiss.github.io/birdnetlib Install the birdnetlib package using pip. Ensure Python 3.9+ and prior installation of Tensorflow Lite, librosa, and ffmpeg. ```bash pip install birdnetlib ``` -------------------------------- ### Detection Output Format Source: https://joeweiss.github.io/birdnetlib/getting-started Example structure of the list returned by recording.detections containing species information and confidence scores. ```json [{'common_name': 'House Finch', 'confidence': 0.5744, 'end_time': 12.0, 'scientific_name': 'Haemorhous mexicanus', 'start_time': 9.0, 'label': 'Haemorhous mexicanus_House Finch'}, {'common_name': 'House Finch', 'confidence': 0.4496, 'end_time': 15.0, 'scientific_name': 'Haemorhous mexicanus', 'start_time': 12.0, 'label': 'Haemorhous mexicanus_House Finch'}] ``` -------------------------------- ### Extract feature embeddings Source: https://joeweiss.github.io/birdnetlib/api Use extract_embeddings to get feature vectors instead of classification results. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", ) recording.extract_embeddings() print(recording.embeddings) ``` -------------------------------- ### Analyze audio with LiteAnalyzer Source: https://joeweiss.github.io/birdnetlib/api Initializes the analyzer and processes an audio file. The model is downloaded automatically upon the first instantiation. ```python analyzer = LiteAnalyzer() recording = Recording( analyzer, "sample.mp3", lat=35.4244, lon=-120.7463, date=datetime(year=2022, month=5, day=10), # use date or week_48 min_conf=0.25, ) recording.analyze() print(recording.detections) # Returns list of detections. ``` -------------------------------- ### Analyze Audio with Analyzer Source: https://joeweiss.github.io/birdnetlib/getting-started Initialize the Analyzer and process a recording file to identify bird species. Requires providing latitude, longitude, and date for accurate model inference. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer from datetime import datetime # Load and initialize the BirdNET-Analyzer models. analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", lat=35.4244, lon=-120.7463, date=datetime(year=2022, month=5, day=10), # use date or week_48 min_conf=0.25, ) recording.analyze() print(recording.detections) ``` -------------------------------- ### Initialize LiteAnalyzer Source: https://joeweiss.github.io/birdnetlib/api Initialize the legacy LiteAnalyzer class. ```python from birdnetlib import Recording from birdnetlib.analyzer_lite import LiteAnalyzer from datetime import datetime # Load and initialize the BirdNET-Lite models. ``` -------------------------------- ### Analyze Audio Files in a Directory with Multiprocessing Source: https://joeweiss.github.io/birdnetlib/utility-classes Employ DirectoryMultiProcessingAnalyzer for asynchronous analysis of audio files in a directory using multiple processes. The results are returned as a list of recordings. ```python def on_analyze_directory_complete(recordings): for recording in recordings: pprint(recording.detections) directory = "." batch = DirectoryMultiProcessingAnalyzer( "/Birds/mp3_dir", patterns=["*.mp3", "*.wav"] ) batch.on_analyze_directory_complete = on_analyze_directory_complete batch.process() ``` -------------------------------- ### Use custom classifier Source: https://joeweiss.github.io/birdnetlib/api Configure the Analyzer with custom model and label files. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer # Load and initialize BirdNET-Analyzer with your own model/labels. custom_model_path = "custom_classifiers/trogoniformes.tflite" custom_labels_path = "custom_classifiers/trogoniformes.txt" analyzer = Analyzer( classifier_labels_path=custom_labels_path, classifier_model_path=custom_model_path ) recording = Recording( analyzer, "sample.mp3", min_conf=0.25, ) recording.analyze() print(recording.detections) ``` -------------------------------- ### Watch a Directory for New Audio Files Source: https://joeweiss.github.io/birdnetlib/utility-classes Utilize DirectoryWatcher to monitor a directory for newly created audio files and automatically analyze them. A callback function is used to process each analyzed recording. ```python 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() ``` -------------------------------- ### Analyze a recording file Source: https://joeweiss.github.io/birdnetlib/api Basic usage of the Recording class to analyze an audio file from disk. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", min_conf=0.25, ) recording.analyze() print(recording.detections) ``` -------------------------------- ### Analyze Audio Files in a Directory Source: https://joeweiss.github.io/birdnetlib/utility-classes Use DirectoryAnalyzer to process all audio files matching specified patterns within a directory. Define a callback function to handle analysis results. ```python def on_analyze_complete(recording): print(recording.path) pprint(recording.detections) directory = DirectoryAnalyzer( "/Birds/mp3_dir", patterns=["*.mp3", "*.wav"] ) directory.on_analyze_complete = on_analyze_complete directory.process() ``` -------------------------------- ### Analyze in-memory file object Source: https://joeweiss.github.io/birdnetlib/api Use RecordingFileObject to process audio data stored in memory. ```python with io.BytesIO(r.content) as fileObj: recording = RecordingFileObject( analyzer, fileObj, lat=35.6, lon=-77.3, date=datetime(year=2023, month=6, day=27), # use date or week_48 min_conf=0.25, ) recording.analyze() pprint(recording.detections) ``` -------------------------------- ### Analyze Audio with BirdNET-Analyzer Source: https://joeweiss.github.io/birdnetlib Use the Analyzer class to load BirdNET-Analyzer models and process an audio file. Specify latitude, longitude, and date for accurate analysis. The 'recording.detections' attribute will contain a list of detected species with confidence scores and time ranges. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer from datetime import datetime # Load and initialize the BirdNET-Analyzer models. analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", lat=35.4244, lon=-120.7463, date=datetime(year=2022, month=5, day=10), # use date or week_48 min_conf=0.25, ) recording.analyze() print(recording.detections) ``` ```python [{'common_name': 'House Finch', 'confidence': 0.5744, 'end_time': 12.0, 'scientific_name': 'Haemorhous mexicanus', 'start_time': 9.0, 'label': 'Haemorhous mexicanus_House Finch'}, {'common_name': 'House Finch', 'confidence': 0.4496, 'end_time': 15.0, 'scientific_name': 'Haemorhous mexicanus', 'start_time': 12.0, 'label': 'Haemorhous mexicanus_House Finch'}] ``` -------------------------------- ### Initialize specific analyzer version Source: https://joeweiss.github.io/birdnetlib/api Specify the model version when initializing the Analyzer class. ```python # Load and initialize the BirdNET-Analyzer 2.3 model. analyzer = Analyzer(version="2.3") ``` -------------------------------- ### Filter detections by location and date Source: https://joeweiss.github.io/birdnetlib/api Use lat, lon, and date arguments to filter detections based on species presence. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", min_conf=0.25, lat=35.6, lon=-77.3, date=datetime(year=2023, month=6, day=27), ) recording.analyze() print(recording.detections) ``` -------------------------------- ### Annotate detections with occurrence prediction Source: https://joeweiss.github.io/birdnetlib/api Set return_all_detections to True to include an occurrence prediction flag for each detection. ```python from birdnetlib import Recording from birdnetlib.analyzer import Analyzer analyzer = Analyzer() recording = Recording( analyzer, "sample.mp3", min_conf=0.25, lat=35.6, lon=-77.3, date=datetime(year=2023, month=6, day=27), return_all_detections=True, ) recording.analyze() print(recording.detections) ``` -------------------------------- ### Predict Species List by Location and Date Source: https://joeweiss.github.io/birdnetlib/utility-classes Use SpeciesList to predict a list of bird species based on geographical coordinates and a specific date. The output includes scientific name, common name, and prediction threshold. ```python species = SpeciesList() species_list = species.return_list( lon=-120.7463, lat=35.4244, date=datetime(year=2022, month=5, day=10) ) print(species_list) # [{'scientific_name': 'Haemorhous mexicanus', 'common_name': 'House Finch', 'threshold': 0.8916686}, ...] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.