MFCC extraction for audio files in a folder

조회 수: 14 (최근 30일)
Camille Dingam
Camille Dingam 2020년 12월 9일
편집: Mary Jeethu A J 2021년 9월 17일
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

채택된 답변

jibrahim
jibrahim 2020년 12월 9일
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
Camille Dingam
Camille Dingam 2020년 12월 10일
Hello, thank you for your answer it is really helpful, so after storing the result in the cell array, the next step is to extract the mean of each column(13) belonging to each file to form just one row values of mfcc features for each file? And other question is if i want to extand the dimension from 13 to 60, what should i change in the code? Thank you again for your help, i really appreciate it.
Mary Jeethu A J
Mary Jeethu A J 2021년 9월 17일
편집: Mary Jeethu A J 2021년 9월 17일
Could you please share the code for extracting the mean of each column?
Thanking you in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Camille Dingam
Camille Dingam 2020년 12월 10일
Hello, thank you for your answer it is really helpful, so after storing the result in the cell array, the next step is to extract the mean of each column(13) belonging to each file to form just one row values of mfcc features for each file? And other question is if i want to extand the dimension from 13 to 60, what should i change in the code? Thank you again for your help, i really appreciate it.

카테고리

Help CenterFile Exchange에서 Speech Recognition에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by