Description Usage Arguments Details Value Examples
split audio file into chunks of regular or irregular length
1 2 | split_audio(filein, split, pathout = NULL, ndigits = NULL,
pathtosox = getOption("avutils_sox"))
|
filein |
character, path to input audio |
split |
numeric or a data.frame, see details |
pathout |
character, path were output is stored, by default the same as the source |
ndigits |
numeric, the number of characters a time step should comprise (see details and |
pathtosox |
character, path to sox binary |
The split=
argument can be supplied in two ways. If you supply a single number the input file will be split into files of equal lengths (determined by split=
in seconds). If you supply a data.frame, it is assumed this is a .rttm file, where the fourth column reflects the starting point and the fifth column determines the length of the segment (in the unit of seconds).
Output files have the time stamps appended in the file name (unit of milliseconds) in the form of filename_fromtime_totime.wav. The ndigits=
argument determines the number of characters the two time chunks have.
a vector with the paths to the split files
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 | ## Not run:
set_binaries(pathtoffmpeg = "~/Documents/utilities/ffmpeg",
pathtosox = "~/Documents/utilities/sox")
tdir <- tempdir()
w1 <- sine(freq = 440, duration = 1.3, bit = 32, stereo = TRUE, xunit = "time")
writeWave(w1, filename = file.path(tdir, "file1.wav"))
tdir
x <- list.files(tdir, pattern = "\\.wav$", full.names = TRUE)
audio_info(filein = x)
y <- split_audio(filein = x, split = 0.4)
audio_info(filein = y)
x <- system.file("synthetic_speech.wav", package = "avutils")
res <- split_audio(filein = x, split = 10, pathout = tdir)
audio_info(filein = res)
# remove files
file.remove(res)
# using an .rttm file as input
split <- read.table(system.file("opensmileSad_synthetic_speech.rttm", package = "avutils"))
head(split)
res <- split_audio(filein = x, split = split, pathout = tdir)
audio_info(filein = res)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.