From d3747c57f20bb1a213cf4a3adcbbc4fdd4b3c833 Mon Sep 17 00:00:00 2001 From: Kavi Askholm Mellerup <111115633+kaviecos@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:20:20 +0200 Subject: [PATCH 1/2] Update README.md Added section for using the API with HTTP. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index e128ec6..55a692b 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,26 @@ detections, features = api.process_spectrogram(spec) You can integrate the detections or the extracted features to your custom analysis pipeline. +#### Using the Python API with HTTP + +```python +from batdetect2 import api +import io +import requests + +AUDIO_URL = "" + +# Process a whole file +results = api.process_url(AUDIO_URL) + +# Or, load audio and compute spectrograms +audio = api.load_audio(io.BytesIO(requests.get(AUDIO_URL).content)) +spec = api.generate_spectrogram(audio) + +# And process the audio or the spectrogram with the model +detections, features, spec = api.process_audio(audio) +detections, features = api.process_spectrogram(spec) +``` ## Training the model on your own data Take a look at the steps outlined in finetuning readme [here](batdetect2/finetune/readme.md) for a description of how to train your own model. From ba670932d56c94f22cadf5fdadbbe9d2d17a2a47 Mon Sep 17 00:00:00 2001 From: Kavi Askholm Mellerup <111115633+kaviecos@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:26:54 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 55a692b..779e6f1 100644 --- a/README.md +++ b/README.md @@ -105,10 +105,11 @@ import requests AUDIO_URL = "" -# Process a whole file +# Process a whole file from a url results = api.process_url(AUDIO_URL) # Or, load audio and compute spectrograms +# 'requests.get(AUDIO_URL).content' fetches the raw bytes. You are free to use other sources to fetch the raw bytes audio = api.load_audio(io.BytesIO(requests.get(AUDIO_URL).content)) spec = api.generate_spectrogram(audio)