| extract_mfcc | R Documentation |
Adds MFCC feature columns (e.g., mfcc1..mfcc13) to a data frame that contains audio file paths and (optionally) segment boundaries.
extract_mfcc(
data,
file_col,
start_col = NULL,
end_col = NULL,
fs = NULL,
numcep = 13,
prefix = "mfcc",
strict = FALSE,
warn = TRUE,
...
)
data |
Data frame containing audio paths and segment boundaries. |
file_col |
String; column name containing WAV file paths. |
start_col |
Optional string; column name containing segment start time
(in seconds). If |
end_col |
Optional string; column name containing segment end time
(in seconds). If |
fs |
Optional numeric; override sampling rate (Hz). If |
numcep |
Integer; number of MFCC coefficients to return. |
prefix |
String; prefix for output columns (default |
strict |
Logical; if |
warn |
Logical; if |
... |
Additional arguments passed to |
This function uses tuneR to read WAV files and compute MFCCs. The package is optional; if it is not installed, an informative error is raised.
The input data frame with added MFCC columns.
if (requireNamespace("tuneR", quietly = TRUE)) {
wav_path <- tempfile(fileext = ".wav")
wave <- tuneR::sine(
freq = 440, duration = 0.25, samp.rate = 16000, xunit = "time"
)
tuneR::writeWave(wave, wav_path)
segments <- data.frame(wav_path = wav_path)
mfcc <- extract_mfcc(segments, file_col = "wav_path", numcep = 3)
unlink(wav_path)
mfcc[, c("mfcc1", "mfcc2", "mfcc3")]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.