Description Usage Arguments Value Author(s) Examples
This fucntion wil download and trim a recording to match an annotated section of recording on BioAcoustica.
1 | bioacoustica.getAnnotationFile(annotation_id, c, data=bioacoustica::bioacoustica.getAnnotations(c))
|
annotation_id |
The annotation ID of the annotation on BioAcoustica. |
c |
An authenticated CURL handle. |
data |
Annotation data. Previosuly downloaded annotation downloads can be passed to the function to prevent multiple calls to BioAcoustica which may cause access to be tmeporarily suspended. If not provided the annotation data will be downloaded from BioAcoustica. |
The filename to a downloaded sound recording.
Ed Baker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(annotation_id, c) {
a <- bioacoustica::bioacoustica.getAnnotations(c);
file <- as.character(subset(a,
a$id==annotation_id,
select="file")[1,1]);
parts <- strsplit(file, "/");
filename <- parts[[1]][7];
#TODO: CHange to CURL
download.file(file, destfile=filename);
long <- tuneR::readWave(filename);
f <- long@samp.rate;
wave <- seewave::cutw(long, f=f, from=subset(a, id==annotation_id,
select="start")[1,1],
to=subset(a, id==annotation_id,select="end")[1,1],
method="Wave");
file.remove(filename);
nf <- paste0(filename,".",annotation_id,".wav");
seewave::savewav(wave, f=f, file=nf);
return(nf)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.