I'm extracting some features from audiofiles with the package "seewave". Specifically, I'm trying to get the resulting features when removing silences -such as duration of the signal and pauses-, with the function zapsilw. I have no problem when getting just one audio, but I'm missing something when running the loop. My code goes something like this:
cut_sound <- rep(NA, length(audio_files))
for (i in 1:length(audio_files))
tmp <- readWave(paste('directory'), audio_files[i], sep='\'))
cut_sound[i] <- zapsilw(tmp, threshold = 2)
duration_sound <- duration(cut_sound[i])
The error is: In cut_sound[i] <- zapsilw(tmp, threshold = 2) : number of items to replace is not a multiple of replacement length. What I am trying to get is a new variable with the duration of the new sound with the pauses removed. zapsilw generates a new wave with the pauses removed and plots it. When running the code, I see how each new wave is being generated, but at the end I received that warning message and no duration. I wonder if it may be something related to that, I mean, If I need the new waves, I should storing them in some part in order to retrieve the duration?