04-data-annotation.Rmd
library(mestrado)
Annotate audio is the most laborous (and maybe tedious) part of any machine learning project. You are lucky if the labels are already there for you. The main package in this section is {wavesurfer}.
# remotes::install_github("athospd/wavesurfer")
library(wavesurfer)
Here it is a working example:
where_I_want_to_store_the_annotations <- tempdir()
annotator_app(
wavs_folder = system.file("wav_sample", package = "mestrado"),
annotations_folder = where_I_want_to_store_the_annotations
)
The inputs are two folders: one indicating where the wave files are and other indicating where you want to store the acutal annotations. The Shiny app migth look like this:
The final product of each annotation is a tibble
. Example follows:
audio_id | region_id | start | end | label |
---|---|---|---|---|
Glaucidium-minutissimum-24426.wav | 75b415rrqd8 | 0.19 | 1.41 | Glaucidium-minutissimum |
Glaucidium-minutissimum-24426.wav | 4nt181nsvl | 4.26 | 5.56 | Glaucidium-minutissimum |
Glaucidium-minutissimum-24426.wav | ootdh1hriqg | 8.55 | 10.18 | Glaucidium-minutissimum |
Glaucidium-minutissimum-24426.wav | ar4jis448p | 13.92 | 15.37 | Glaucidium-minutissimum |
Glaucidium-minutissimum-24426.wav | 7i7a77cqqsg | 19.59 | 21.26 | Glaucidium-minutissimum |
Glaucidium-minutissimum-24426.wav | oubnm1mie9 | 24.55 | 26.29 | Glaucidium-minutissimum |
And that’s all! Once annotated, you are ready to go to the labelling task.
PS: you can find samples of these tibbles inside the package:
system.file("annotations", package = "mestrado") %>%
list.files(full.names = TRUE)
#> [1] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Glaucidium-minutissimum-24426.rds"
#> [2] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Megascops-atricapilla-1261496.rds"
#> [3] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Megascops-atricapilla-1393458.rds"
#> [4] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Megascops-choliba-118111.rds"
#> [5] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Megascops-choliba-1891062.rds"
#> [6] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Pulsatrix-koeniswaldiana-365658.rds"
#> [7] "/tmp/Rtmp5PtfF0/temp_libpath2fc46d094fd/mestrado/annotations/Pulsatrix-koeniswaldiana-393745.rds"