Hi Audiomoth Fans,
I'm searching how to extract the temperature data from any audiomoth recording. I tried using seewave & tuneR from R environment. Does any way to extract this data?

Hi Audiomoth Fans,
I'm searching how to extract the temperature data from any audiomoth recording. I tried using seewave & tuneR from R environment. Does any way to extract this data?
Hi Cristian, There's a Python script in the Applications Notes folder - https://github.com/OpenAcousticDevices/Application-Notes/blob/master/AudioMoth_Temperature_Measurements.pdf - which will extract the temperature and battery data from all the files. The header comment is always in the same place in the files, and this script just parses it as text and extracts the relevant data. Alex
This looks great. I don't think it will read negative temperatures so you should update that if it's an issue. The header is always less than 512 bytes long so you can just read the first 512 characters from each file. That might speed it up.
Hello all, my coworker helped me out and created this R script. Very straight forward. It takes a while to run on a large number of files.
The export is a data.frame of metadata:
AudioMothID File Recorded Battery_V Temperature_C 24F319055F5775E5 file.wav 2021-04-14 23:53:39 4.2 23.1
# this lists all the *.wav files in a folder. # if you have many files this will list them all with the full # directory path wavfiles <- list.files("C:/User/", pattern = ".wav", full.names = TRUE) # this simple call will go through all the files, # extract the data you want, and put it into a data frame #run function below first allmetadata <- do.call(rbind,lapply(wavfiles, getWavMetaData)) # BELOW IS A FUNCTION TO EXTRACT ALL THE METADATA # # Params # @wavfiles = path to *.wav files of interest to extract data # @filenames = optional vector of file names for the *.wav files - should be save length # as wavfiles and in same order getWavMetaData <- function(wavfiles, filenames = NULL){ # parse out the file name - this assumes the full path is given # if(is.null(filenames)){ if(sum(grep(pattern = "\\/", wavfiles))!=0L){ fileID <- gsub(".*/","",wavfiles)}else{ fileID <- wavfiles } }else{ fileID <- filenames } # how many characters at in the file # size <- readBin(wavfiles, integer(), size = 4, endian = "little") # read in the data # binDat <- suppressWarnings(readBin(wavfiles, "character", n = size)) # determine which element of the list has what you want # metadat <- binDat[which(grepl("Recorded",binDat))] # grab the different metadata components # date_time <- regexpr(pattern = "Recorded at \\d*:\\d*:\\d*\\d*\\/\\d*\\/\\d*", text = metadat[1]) # Get date location in string # timeLoc <- regexpr(pattern = "[0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{2}\\/[0-9]{2}\\/[0-9]{4}", text = metadat[1]) # Get voltage data location in string # voltLoc <- regexpr("[0-9].[0-9]V", metadat[1]) # Get temp. da