Skip to content

leabouffaut/bioacoustics_python

Repository files navigation

Bioacoustics in Python

by Léa Bouffaut, Ph.D. -- K. Lisa Yang Center for Conservation Bioacoustics -- lea.bouffaut@cornell.edu

This repository aims to provide helpful code examples for bioacoustics in Python and uses Jupyter Notebooks. At the moment, the following examples are available:

  • AudioManipulating/, a quick tutorial on how to safely resample audio files and choose the output audio file format
  • ModelPerformancEvaluation/ is used to evaluate automatic detection algorithms that assign a classification score to audio files that are divided into potentially overlapping audio clips of flexible duration (e.g., BirdNET or Koogu-trained models). It generates precision-recall curves based on Raven selection tables for the ground truth and model output.
  • Spectrogram/ is a quick tutorial to load an audio file and generate and save your own spectrogram!
  • RavenSelectionTable/, provides an example of how to load and manipulate Raven selection tables, including a quick how-to to generate your own audio clips!

--- New to Python? ---

Python is a programming language that can be programmed from many different interfaces. But, using the terminal is not super interactive and can be scary to start (also, for projects, it is impractical). So, people usually use development environments, e.g., Pycharm or Spyder, to code. It gives you a nicer interface for your projects and usually comes with some help (think, when you write a Word document and have grammar suggestions, auto-completion, etc.). I would recommend starting with Jupyter Notebooks. It is a super friendly environment and allows you to have a lot of interactions with the code.

So first, I'd recommend familiarizing yourself with Python basics and Jupyter Notebooks! Here are a couple of helpful tutorials:

S'more tips from my personal experience

Tip 1: Get a grasp of the vocab' and grammar! The videos below should help but get familiar with

Tip 2: Get familiar with virtual environments Virtual environements are generally created for each project, and allow you to select which Python version you wish to work with as well as contain the functions and modules you are using. Standard development environements will create them automatically, here are some guidelines for Jupyter Lab https://medium.com/@laquesisa/virtual-environment-in-jupyter-lab-8b3815ba9662

Tip 23: Start with a project that you find fun! Some ideas with examples: https://www.dataquest.io/blog/python-projects-for-beginners/ If your goal is to learn to manipulate data, check out "Fun Python Project Ideas for Building Data Skills" section. If you find it fun, you will want to get back to it, and it'll be easier to dedicate time to figure things out.

Tip 4: Practice Algorithmic! Meaning, structure your code as you would for a research paper. What is the objective of this piece of code? How would you break it down into simpler "logical" tasks?

Tip 5: Google your way! You do not need to remember all functions. Some, of course, you will remember by practicing. For most, you might have to Google it, and that's okay! What is essential is to learn how to do a Google search to find valuable information. :)

Tip 6: Document your code! It is good practice to document your code, and starting by drafting your English version of the algorithm should help. But even more, don't hesitate to add comments, explain why you're doing things one way and not another etc.

Tip 7: Use explicit variable names! I remember when I started, all my variables were named x1, x2, y3... It was an absolute hell for other people to read my code. Now, if x1 became day and y3 became temperature_daily, all of the sudden, it is a lot clearer to everyone! You can use the Tab key for autocompletion.

Tip 8: Read other people's code! Like learning a foreign language, it will help discover new ways of getting a specific task done and it will help broaden your "code literacy." As for a foreign language you're reading, there might be words (e.g., functions) or grammatical tools (e.g., code structure) you are unfamiliar with: back to tip 4... Google it!

About

Helpful code exemples for bioacoustics in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published