Blog‎ > ‎

Download a Single Recording for Each Bird Species from a Country

posted Jun 25, 2019, 6:17 PM by MUHAMMAD MUN`IM AHMAD ZABIDI   [ updated Jun 25, 2019, 10:51 PM ]
Xeno-Canto.org is THE database for bird sounds from around the world.
Each recordng is in MP3, with metadata tagging bird name in English, scientific name, place and time of recording, recording quality, type of recording (song, call, etc).


Comments in Grey. Commands in Blue. Outputs in Yellow.

#run it only if devtools isn't installed
install.packages("devtools")
devtools::install_github("maRce10/warbleR")
require("warbleR")

CR.recs <- querxc(qword = 'cnt:"malaysia"', download = FALSE)
   |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 44s
7626 recordings found!

#number of recordings
nrow(CR.recs)
[1] 7626
#order by quality to get highest quality recording for each species
CR.recs <- CR.recs[order(order(match(CR.recs$Quality,c("A", "B", "C", "D", "E", "no score")))),]
#subset in song and no-songs
CR.songs <- CR.recs[grep("song", CR.recs$Vocalization_type, ignore.case = T),]
CR.no.songs <- CR.recs[grep("song",CR.recs$Vocalization_type, ignore.case = T, invert = T),]
# remove duplicates by species
CR.songs <- CR.songs[!duplicated(CR.songs$English_name),]
# in my case, I want only A quality recordings
CR.a = CR.songs[grep("A",CR.songs$Quality,ignore.case=T,),]
nrow(CR.a)
[1] 295
# download using filtered metadata
querxc(X = CR.a)
   |+++++++++++++++++++++++                           | 45% ~14m 12s     

It takes 20-30 minutes to download all the MP3 files. There's A quality recordings for 295 species in Malaysia.



Comments