{
# load example data
data("lbh1", "lbh2", "lbh_reference")
tuneR::writeWave(lbh1, file.path(tempdir(), "lbh1.wav"))
tuneR::writeWave(lbh2, file.path(tempdir(), "lbh2.wav"))
## if X is a data frame #####
df_ref <- as.data.frame(lbh_reference)
# get split annotations
split_df_ref <- split_acoustic_data(X = df_ref,
only.sels = TRUE, sgmt.dur = 1.5,
path = tempdir(), pb = FALSE,
files = c("lbh1.wav", "lbh2.wav"))
# get clip information
Y <- split_acoustic_data(sgmt.dur = 1.5,
path = tempdir(), pb = FALSE,
output.path = tempdir(), files = c("lbh1.wav", "lbh2.wav"))
# reassemble annotations
tc <- reassemble_detection(detection = split_df_ref,
Y = Y, pb = FALSE)
# start and end are the same as in the original unsplit data
df_ref <- df_ref[order(df_ref$sound.files, df_ref$start), ]
all(tc$end == df_ref$end)
all(tc$start == df_ref$start)
### if X is a selection table ##
# split annotations and files
split_lbh_reference <- split_acoustic_data(X = lbh_reference,
sgmt.dur = 1.5, path = tempdir(),
output.path = tempdir(),
files = c("lbh1.wav", "lbh2.wav"))
# reassemble annotations
tc <- reassemble_detection(detection = split_lbh_reference,
Y = attributes(split_lbh_reference)$clip.info)
# start and end are the same as in the original unsplit data
lbh_reference <- lbh_reference[order(lbh_reference$sound.files, lbh_reference$start), ]
all(tc$end == lbh_reference$end)
all(tc$start == lbh_reference$start)
}
Run the code above in your browser using DataLab