OpenSoundscape
A free and open source Python utility library analyzing bioacoustic data.
https://github.com/kitzeslab/opensoundscape
Category: Biosphere
Sub Category: Bioacoustics and Acoustic Data Analysis
Last synced: about 2 hours ago
JSON representation
Repository metadata
Open source, scalable software for the analysis of bioacoustic recordings
- Host: GitHub
- URL: https://github.com/kitzeslab/opensoundscape
- Owner: kitzeslab
- License: mit
- Created: 2018-09-17T20:14:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-13T19:48:29.000Z (about 2 months ago)
- Last Synced: 2025-04-17T23:55:13.279Z (13 days ago)
- Language: Python
- Homepage: http://opensoundscape.org
- Size: 416 MB
- Stars: 162
- Watchers: 10
- Forks: 21
- Open Issues: 83
- Releases: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
OpenSoundscape
OpenSoundscape (OPSO) is free and open source Python utility library analyzing bioacoustic data.
OpenSoundscape includes utilities which can be strung together to create data analysis pipelines, including functions to:
- load and manipulate audio files
- create and manipulate spectrograms
- train deep learning models to recognize sounds
- run pre-trained CNNs to detect vocalizations
- tune pre-trained CNNs to custom classification tasks
- detect periodic vocalizations with RIBBIT
- load and manipulate Raven annotations
- estimate the location of sound sources from synchronized recordings
OpenSoundscape's documentation can be found on OpenSoundscape.org.
Show me the code!
For examples of how to use OpenSoundscape, see the Quick Start Guide below.
For full API documentation and tutorials on how to use OpenSoundscape to work with audio and spectrograms, train machine learning models, apply trained machine learning models to acoustic data, and detect periodic vocalizations using RIBBIT, see the documentation.
Contact & Citation
OpenSoundcape is developed and maintained by the Kitzes Lab at the University of Pittsburgh. It is currently in active development. If you find a bug, please submit an issue on the GitHub repository. If you have another question about OpenSoundscape, please use the (OpenSoundscape Discussions board)[https://github.com/kitzeslab/opensoundscape/discussions] or email Sam Lapp (sam.lapp at pitt.edu
)
Suggested citation:
Lapp, Sam; Rhinehart, Tessa; Freeland-Haynes, Louis;
Khilnani, Jatin; Syunkova, Alexandra; Kitzes, Justin.
“OpenSoundscape: An Open-Source Bioacoustics Analysis Package for Python.”
Methods in Ecology and Evolution 2023. https://doi.org/10.1111/2041-210X.14196.
Quick Start Guide
A guide to the most commonly used features of OpenSoundscape.
Installation
Details about installation are available on the OpenSoundscape documentation at OpenSoundscape.org. FAQs:
How do I install OpenSoundscape?
- Most users should install OpenSoundscape via pip, preferably within a virtual environment:
pip install opensoundscape==0.12.0
. - To use OpenSoundscape in Jupyter Notebooks (e.g. for tutorials), follow the installation instructions for your operating system, then follow the "Jupyter" instructions.
- Contributors and advanced users can also use Poetry to install OpenSoundscape using the "Contributor" instructions
Will OpenSoundscape work on my machine?
- OpenSoundscape can be installed on Windows, Mac, and Linux machines.
- It has been tested on Python 3.9, 3.10, and 3.11.
- For Apple Silicon (M1 chip) users, Python >=3.9 is recommended and may be required to avoid dependency issues.
- Most computer cluster users should follow the Linux installation instructions
Use Audio and Spectrogram classes to inspect audio data
from opensoundscape import Audio, Spectrogram
#load an audio file and trim out a 5 second clip
my_audio = Audio.from_file("/path/to/audio.wav")
clip_5s = my_audio.trim(0,5)
#create a spectrogram and plot it
my_spec = Spectrogram.from_audio(clip_5s)
my_spec.plot()
Load audio starting at a real-world timestamp
from datetime import datetime; import pytz
start_time = pytz.timezone('UTC').localize(datetime(2020,4,4,10,25))
audio_length = 5 #seconds
path = '/path/to/audiomoth_file.WAV' #an AudioMoth recording
Audio.from_file(path, start_timestamp=start_time,duration=audio_length)
Load and use a model from the Bioacoustics Model Zoo
The Bioacoustics Model Zoo hosts models in a repository that can be installed as a package and are compatible with OpenSoundscape. To install, use
pip install git+https://github.com/kitzeslab/bioacoustics-model-zoo
Load up a model and apply it to your own audio right away:
import bioacoustics_model_zoo as bmz
#list available models
print(bmz.utils.list_models())
#generate class predictions and embedding vectors with Perch
perch = bmz.Perch()
scores = perch.predict(files)
embeddings = perch.generate_embeddings(files)
#...or BirdNET
birdnet = bmz.BirdNET()
scores = birdnet.predict(files)
embeddings = birdnet.generate_embeddings(files)
See the tutorial notebooks for examples of training and fine-tuning models from the model zoo with your own annotations.
Load a pre-trained CNN from a local file, and make predictions on long audio files
from opensoundscape import load_model
#get list of audio files
files = glob('./dir/*.WAV')
#generate predictions with a model
model = load_model('/path/to/saved.model')
scores = model.predict(files)
#scores is a dataframe with MultiIndex: file, start_time, end_time
#containing inference scores for each class and each audio window
Train a CNN using audio files and Raven annotations
from sklearn.model_selection import train_test_split
from opensoundscape import BoxedAnnotations, CNN
# assume we have a list of raven annotation files and corresponding audio files
# load the annotations into OpenSoundscape
all_annotations = BoxedAnnotations.from_raven_files(raven_file_paths,audio_file_paths)
# pick classes to train the model on. These should occur in the annotated data
class_list = ['IBWO','BLJA']
# create labels for fixed-duration (2 second) clips
labels = all_annotations.clip_labels(
clip_duration=2,
clip_overlap=0,
min_label_overlap=0.25,
class_subset=class_list
)
# split the labels into training and validation sets
train_df, validation_df = train_test_split(labels, test_size=0.3)
# create a CNN and train on the labeled data
model = CNN(architecture='resnet18', sample_duration=2, classes=class_list)
# train the model to recognize the classes of interest in audio data
model.train(train_df, validation_df, epochs=20, num_workers=8, batch_size=256)
Train a custom classifier on BirdNET or Perch embeddings
Make sure you've installed the model zoo in your Python environment:
pip install git+https://github.com/kitzeslab/bioacoustics-model-zoo
import bioacoustics_model_zoo as bmz
# load a model from the model zoo
model = bmz.BirdNET() #or bmz.Perch()
# define classes for your custom classifier
model.change_classes(train_df.columns)
# fit the trainable PyTorch classifier on your labels
model.train(train_df,val_df,num_augmentation_variants=4,batch_size=64)
# run inference using your custom classifier on audio data
model.predict(audio_files)
# save and load customized models
model.save(save_path)
reloaded_model = bmz.BirdNET.load(save_path)
Owner metadata
- Name: kitzeslab
- Login: kitzeslab
- Email:
- Kind: organization
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/47861642?v=4
- Repositories: 6
- Last ynced at: 2023-03-08T16:44:28.840Z
- Profile URL: https://github.com/kitzeslab
GitHub Events
Total
- Create event: 10
- Release event: 1
- Issues event: 58
- Watch event: 30
- Delete event: 4
- Issue comment event: 35
- Push event: 51
- Pull request review event: 1
- Pull request event: 15
- Fork event: 4
Last Year
- Create event: 10
- Release event: 1
- Issues event: 58
- Watch event: 30
- Delete event: 4
- Issue comment event: 35
- Push event: 51
- Pull request review event: 1
- Pull request event: 15
- Fork event: 4
Committers metadata
Last synced: 1 day ago
Total Commits: 1,902
Total Committers: 17
Avg Commits per committer: 111.882
Development Distribution Score (DDS): 0.42
Commits in past year: 349
Committers in past year: 6
Avg Commits per committer in past year: 58.167
Development Distribution Score (DDS) in past year: 0.272
Name | Commits | |
---|---|---|
sammlapp | s****p@g****m | 1103 |
rhine3 | t****t@g****m | 353 |
Louis Freeland-Haynes | 6****h | 144 |
Barry Moore | c****l@g****m | 104 |
Santiago Ruiz Guzman | s****1@p****u | 50 |
syunkova | s****a@g****m | 33 |
Lapp | s****1@r****u | 31 |
Jatin Khilnani | j****3@n****u | 30 |
LeonardoViotti | l****i@g****m | 17 |
Justin Kitzes | j****s@p****u | 17 |
Alexandra Syunkova | s****h@A****l | 6 |
Zohar | j****2@p****u | 4 |
Jatin Khilnani | jk@n****l | 3 |
Freeland-Haynes | L****9@F****l | 2 |
sar541 | s****z@g****m | 2 |
Lapp | S****1@d****t | 2 |
ter38 | t****8@l****u | 1 |
Committer domains:
- pitt.edu: 3
- login1.crc.pitt.edu: 1
- dsas-r2ghwxk40d.hsd1.pa.comcast.net: 1
- nyu.edu: 1
- robin.bio.pitt.edu: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 357
Total pull requests: 142
Average time to close issues: 7 months
Average time to close pull requests: 29 days
Total issue authors: 24
Total pull request authors: 9
Average comments per issue: 1.35
Average comments per pull request: 0.32
Merged pull request: 98
Bot issues: 0
Bot pull requests: 22
Past year issues: 94
Past year pull requests: 53
Past year average time to close issues: 3 months
Past year average time to close pull requests: 23 days
Past year issue authors: 14
Past year pull request authors: 6
Past year average comments per issue: 0.91
Past year average comments per pull request: 0.3
Past year merged pull request: 33
Past year bot issues: 0
Past year bot pull requests: 7
Top Issue Authors
- sammlapp (235)
- louisfh (65)
- rhine3 (17)
- syunkova (8)
- paulpeyret-biophonia (4)
- jatinkhilnani (3)
- Maxime-Bru (3)
- lmc150 (3)
- jhuus (2)
- WMXZ-EU (2)
- lydiakatsis (2)
- fascimare (1)
- w-out (1)
- smholmes3 (1)
- Mgallimore88 (1)
Top Pull Request Authors
- sammlapp (83)
- dependabot[bot] (22)
- louisfh (20)
- syunkova (6)
- sanruizguz (3)
- rhine3 (3)
- LeonardoViotti (3)
- bmford (1)
- jkitzes (1)
Top Issue Labels
- resolved_in_develop (175)
- feature request (63)
- bug (55)
- docs (39)
- module:ml (26)
- module:localization (23)
- discuss (22)
- module:preprocessing (16)
- high priority (15)
- module:annotation (13)
- deprecation (11)
- resolved_in_branch (10)
- dependencies (7)
- in_progress (6)
- performance (6)
- rename (4)
- testing (3)
- module:wandb (2)
- system:mps (2)
- blocked (2)
- good first issue (1)
- wontfix (1)
Top Pull Request Labels
- dependencies (22)
- resolved_in_develop (5)
- python (3)
Dependencies
- docutils <0.18
- ipykernel *
- m2r *
- nbsphinx *
- sphinx >=1.4
- actions/checkout v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- python 3.7-slim build
Score: 8.334471554600944