knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(sonicscrewdriver)
The sonicscrewdriver
package provides a number of functions for interacting with other audio tools and software. This vignette provides an overview of the functions available for interacting with other tools.
Label files exported from Audacity can be read into R using the readAudacityLabels()
function. This function takes a path to a label file and returns a list of Annotation
objects or a data frame with the start and end times of each label and the label text. The writeAudacityLabels()
function can be used to write a list of Annotation
objects to an Audacity label file.
The audioBlast API can be accessed using the audioBlast()
function. Files can be downloaded from the API using the audioBlastDownload()
function.
AudioMoth configuration files and wave files can be read into R using the audiomothConfig()
and audiomothWave()
functions, respectively. The audiomothConfig()
function takes a path to a configuration file and returns a data frame of the configuration settings. The audiomothWave()
function takes a path to a wave file and returns a list of extracted parameters.
BirdNET Analyzer is a deep learning model for the automatic detection of bird sounds. The birdNetInstall()
function can be used to install the ssd_birdnet
environment required to use the birdNetAnalyse()
function with SonicScrewdriver
. The birdNetAnalyse()
function takes a list of sound files and analyses them using the BirdNET-Analyzer
. The function either returns a data frame with the results of the analysis or a list of Annotation
objects.
# Install the Python environment pythonInstall()
# Analyse sound files using BirdNET-Analyzer f <- system.file("extdata", "AUDIOMOTH.WAV", package="sonicscrewdriver") birdNetAnalyse(f, lat=51.5, lon=0.1, date=as.Date("2021-01-01"))
scikit-maad is an open source Python package dedicated to the quantitative analysis of environmental audio recordings. sonicscrewdriver
makes use of the reticulate
package to create a Python environment and to interact with scikit-maad. In sonicscrewdriver
scikit-maad functions are prefixed with maad_
.
The functions provided accept standard Wave-like objects (i.e. tuneR
Wave
or WaveMC
objects, as well as their tagged equivalents from this package).
# Install the Python environment pythonInstall()
f <- system.file("extdata", "AUDIOMOTH.WAV", package="sonicscrewdriver") w <- readWave(f) maad_aci <- maad_acoustic_complexity_index(w)
The audio file of interest (id: 10754) is a recording of the Mole Cricket Gryllotalpa vineae from the BioAcoustica repository. Recordings and annotations from BioAcoustica are made available through the audioBlast API.
First we will download the audio file and annotations from audioBlast.
# Find the file on audioblast data <- audioblast("data", "recordings", source="bio.acousti.ca", id=10754) # Download the file to the mole_cricket directory audioblastDownload(data, dir="mole_cricket/")
This has downloaded the audio file to the mole_cricket
directory. It has also saved a metadata.csv
file that includes more information about the audio file retrieved from audioBlast.
Next, we will download the annotations for this file from audioBlast.
# Fetch annotations from audioBlast as `Annotation` objects a <- audioblast("data", "annomate", source="bio.acousti.ca", id=10754, output="Annotations")
This has downloaded the annotations from audioBlast and converted them to a list of Annotation
objects. Once annotation data are converted to Annotation
objects they can be easily manipulated into a number of other useful formats.
In this case, we will convert the Annotation
objects to an Audacity label file.
# Convert the annotations to an Audacity label file writeAudacityLabels(a, "mole_cricket/annotations.txt")
When we are finished, we can tidy our workspace by removing the mole_cricket
directory.
unlink("mole_cricket", recursive=TRUE)
The birdNetAnalyse()
function can be used to analyse sound files using the BirdNET-Analyzer
.
Get the output of the BirdNET Analyzer as a list of Annotation
objects.
# Analyse sound files using BirdNET-Analyzer f <- system.file("extdata", "AUDIOMOTH.WAV", package="sonicscrewdriver") annotations <- birdNetAnalyse(f, output="Annotation")
Convert the Annotation
objects to an Audacity label file.
# Convert the annotations to an Audacity label file writeAudacityLabels(annotations, "birdnet_annotations.txt")
Cleaning up the workspace.
unlink("birdnet_annotations.txt")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.