-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadData.m
More file actions
35 lines (31 loc) · 1.02 KB
/
loadData.m
File metadata and controls
35 lines (31 loc) · 1.02 KB
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
26
27
28
29
30
31
32
33
34
35
function g = loadData(train_or_test)
%loadTrainData loads training data into prt Dataset
addpath('rastamat/');
path_to_train_data = dir(train_or_test);
ii = [path_to_train_data(:).isdir];
genres = {path_to_train_data(ii).name}';
genres(ismember(genres,{'.','..'})) = [];
numGenres = length(genres);
g = struct;
for ii=1:numGenres
g(ii).name = path_to_train_data(ii+2).name;
str = sprintf('%s/%s',train_or_test,g(ii).name);
d = dir(str);
g(ii).files = d(3:end);
for jj=3:length(d)
sstr = sprintf('%s/%s',str,d(jj).name);
try
[x,fs]=audioread(sstr);
x = (x(:,1)+x(:,2))/2;
[ceps,~,~]=melfcc(x,fs,'numcep',20,'minfreq',0,'maxfreq',2000);
ceps = ceps';
ceps(:,1:13);
cep_feat = mean(ceps);
g(ii).files(jj-2).ceps = ceps;
g(ii).files(jj-2).features = cep_feat;
catch
fprintf('Likely Corrupted File found at %s. Please delete it before re-running script\n', sstr);
end
end
end
end