필터 지우기
필터 지우기

audio feature extraction wav files inside a folder

조회 수: 6 (최근 30일)
Rita Campos
Rita Campos 2023년 11월 26일
편집: Rita Campos 2023년 11월 28일
I've seen that some questions have been answered to similar questions to mine. They're similar but different enough to not answer my question.
I'm trying to extract several audio features from .wav files located inside a folder.
I need the below code to have a for loop that goes through each .wav file in that folder, extracts all required features for that file, saves the features somewhere (.mat file or excel - not too bothered but actually maybe excel would be easier in this case) and then does this for every .wav file until there are no files left inside that folder.
My code is not built for that and I've been googling and experimenting and can't figure out how to come up with a solution.
Could you please help me?
(I've got audio toolbox installed and my Matlab version is R2023a if it's useful for you at all to know that).
% select the folder path where audio files are located
folderPath = 'C:\Users\Documents\MATLAB\audioExperiment3';
fileList = dir(fullfile(folderPath,'*.wav')); % Change the file extension if needed
ads = audioDatastore(folderPath);
for i = 1:length(fileList)
% Read the audio file
filePath = fullfile(folderPath,fileList(i).name);
[audioIn,fs] = audioread(filePath);
% obj. % adds mfcc to the list of enabled features.
% obj.
% obj.melSpectrum = true
% obj.barkSpectrum = true
% obj.erbSpectrum = true
% obj.mfccDelta = true
% obj.mfccDeltaDelta = true
% obj.gtcc = true
% obj.gtccDelta = true
% obj.gtccDeltaDelta = true
% obj.spectralCrest = true
% obj.spectralDecrease = true
% obj.spectralEntropy = true
% obj.spectralFlatness = true
% obj.spectralFlux = true
% obj.spectralRolloffPoint = true
% obj.spectralSkewness = true
% obj.spectralSlope = true
% obj.spectralSpread = true
% obj.
% obj.zerocrossrate = true
% obj.shortTimeEnergy = true
aFE = audioFeatureExtractor("SampleRate",fs, ...
"SpectralDescriptorInput",...
"barkSpectrum", ...
"spectralCentroid", ...
"spectralKurtosis",...
"pitch",...
"linearSpectrum",...
"mfcc",...
"harmonicRatio");
saveFilePath = fullfile(folderPath,[fileList(i).name '_features.mat']);
save(saveFilePath,'aFE');
end
Also Matlab is showing me this error:
>> AudioFeaturesExtractAudioToolbox_04
Error using set.mfcc
Expected mfcc to be one of these types:
logical, double, single, uint8, uint16, uint32, uint64,
int8, int16, int32, int64
Instead its type was string.
Error in audioFeatureExtractor/set.mfcc (line 1694)
validateattributes(val,{'logical','numeric'}, ...
Error in audioFeatureExtractor (line 444)
set(obj,parsedStruct)
Error in AudioFeaturesExtractAudioToolbox_04 (line 41)
aFE = audioFeatureExtractor("SampleRate",fs, ...
>>
______________________
Thanks in advance for any help if possible.

채택된 답변

Walter Roberson
Walter Roberson 2023년 11월 26일
aFE = audioFeatureExtractor("SampleRate",fs, ...
"SpectralDescriptorInput",...
"barkSpectrum", ...
"spectralCentroid", ...
"spectralKurtosis",...
You are missing a value for spectralCentroid, so it is trying to understand the value of spectralCentroid as being the string object "spectralKurtosis"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Audio Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by