Spectrograms
This tutorial demonstrates how to use OpenSoundscape to create spectrograms from audio files, inspect spectrogram properties, and modify spectrograms.
Run this tutorial
This tutorial is more than a reference! It’s a Jupyter Notebook which you can run and modify on Google Colab or your own computer.
Link to tutorial |
How to run tutorial |
---|---|
The link opens the tutorial in Google Colab. Uncomment the “installation” line in the first cell to install OpenSoundscape. |
|
The link downloads the tutorial file to your computer. Follow the Jupyter installation instructions, then open the tutorial file in Jupyter. |
[1]:
# if this is a Google Colab notebook, install opensoundscape in the runtime environment
if 'google.colab' in str(get_ipython()):
%pip install opensoundscape
Quick start
The “quick start” code below demonstrates a basic pipeline for downloading an audio file, loading it into OpenSoundscape, and creating a spectrogram from it
Import needed classes
Import the Audio
and Spectrogram
classes from OpenSoundscape.
(For more information about Python imports, review this article.)
[64]:
# Import Audio and Spectrogram classes from OpenSoundscape
from opensoundscape import Audio, Spectrogram
#other utilities
from pathlib import Path
Get an example audio file
Here we download an example birdsong soundscape recorded by an AudioMoth autonomous recorder in Pennsylvania, USA.
[5]:
audio_object=Audio.from_url('https://tinyurl.com/birds60s')
# or load a local file:
# a = Audio.from_file('/local/file/path')
audio_object
[5]: