-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTesting_Classifier.m
42 lines (28 loc) · 1.15 KB
/
Testing_Classifier.m
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
36
37
38
39
40
%testing...
% Extract features from test samples and preproccess it...
features_test = [];
labels_test = [];
numVectorsPerFile = [];
while hasdata(ADSTest)
[audioIn,dsInfo] = read(ADSTest);
feat = extract(afe,audioIn);
isSpeech = feat(:,featureMap.shortTimeEnergy) > energyThreshold;
isVoiced = feat(:,featureMap.zerocrossrate) < zcrThreshold;
voicedSpeech = isSpeech & isVoiced;
feat(~voicedSpeech,:) = [];
numVec = size(feat,1);
feat(:,[featureMap.zerocrossrate,featureMap.shortTimeEnergy]) = [];
label = repelem(dsInfo.Label,numVec);
numVectorsPerFile = [numVectorsPerFile,numVec];
features_test = [features_test;feat];
labels_test = [labels_test,label];
dsInfo.FileName
end
features_test = (features_test-M)./S;
%predict label according to trainedClassifier...
prediction = predict(trainedClassifier,features_test);
prediction = categorical(string(prediction));
% plot the result table...
figure(Units="normalized",Position=[0.4 0.4 0.4 0.4])
confusionchart(labels_test(:),prediction,title="Test Accuracy (Per Frame)", ...
ColumnSummary="column-normalized",RowSummary="row-normalized");