Skip to contents

Introduction

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.

Interfaces with other tools

Audacity

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.

AudioBlast

The audioBlast API can be accessed using the audioBlast() function. Files can be downloaded from the API using the audioBlastDownload() function.

AudioMoth

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

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 BirdNET environment
birdNetInstall()
# 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"))

Exemplar applications

Audio file with annotations from audioBlast to Audacity

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)

BirdNET Analyzer to Audacity label file

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")