MFCC extraction for audio files in a folder
14 views (last 30 days)
Show older comments
Hello, below is the code i m working on to extract mfcc features for all audio files in a folder. I want each file with it mfccs features in the term of columns or row, meaning each audio file with mfcc features dimensions(as a vector). If i have 36 audios files in a folder, i want to store the mfcc features of each file in an excel or anywhere with 36 columns or rows which correspond to audio 36 audio files numbers, and their rows or columns which correspond to mfcc features of each audio files, the dimensions of each audio file mfcc features must be the same. I tried with the following code but in vain, i really need help to figure out the problem in my code. The code is:
clc
clear all
file = dir ('D:\FOR AUDIO PREPARATION\F03&FC03\VOWEL_e\F03--FC03\F03\*wav');
M= length (file)
% file = dir ('*.wav');
%
% M= length (file);
NFFT = 128;
for k = 1:10
%pitch extraction
[speech,Fs]= audioread(fullfile('D:\FOR AUDIO PREPARATION\F03&FC03\VOWEL_e\F03--FC03\F03\',file(k).name));
% [speech,Fs]= audioread(file(k).name);
a=(speech);
[coeffs,delta,deltaDelta,loc] = mfcc(speech,Fs);
win = hann(1024,"periodic");
S = stft(imf,"Window",win,"OverlapLength",512,"Centered",false);
coeffs = mfcc(S,Fs,"LogEnergy","Ignore");
data(:,k) = coeffs(:);
end
0 Comments
Accepted Answer
jibrahim
on 9 Dec 2020
Hi Camille,
The size of the output of mfcc, coeffs, is L-by-M for mono audio signals, where L depends on the audio input length, and M is the number of coefficients you asked for (controlled by the NumCoeffs parameter-value pair - it is 13 by default).
If your audio signals are not all of the same length, then L will be different for each file, and you won't be able to put the coefficients in a matrix like you are doing.
You either have to make sure all your signals are of the same length, or you will have to store the MFCC coefficients in a cell array rather than a matrix. For example:
files = dir ('*.wav');
data = cell(1, length(files));
for k = 1:length(files)
[speech,Fs]= audioread(files(k).name);
coeffs = mfcc(speech,Fs,"LogEnergy","Ignore");
data{k} = coeffs;
end
2 Comments
Mary Jeethu A J
on 17 Sep 2021
Edited: Mary Jeethu A J
on 17 Sep 2021
Could you please share the code for extracting the mean of each column?
Thanking you in advance.
More Answers (1)
See Also
Categories
Find more on Speech Recognition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!