dan@0
|
1 function [features] = feature_extraction(segment,config,startStop,minC0)
|
dan@0
|
2 %%
|
dan@0
|
3 % Mobilab 2012-2013
|
dan@0
|
4 %
|
dan@0
|
5 %%
|
dan@0
|
6 if nargin < 4, minC0 = []; end, %minC0 will be placed empty
|
dan@0
|
7 %if nargin < 3, startStop = [0 size(segment,1)/config.fs]; end, %Default no segmentation
|
dan@0
|
8 if nargin < 3, startStop = []; end, %startSop is left empty, no segmentation occurs
|
dan@0
|
9 %%
|
dan@0
|
10 % Calculate the features
|
dan@0
|
11 mel_feat = FE(segment, config);
|
dan@0
|
12 logmel_feat = log(mel_feat);
|
dan@0
|
13 [MM,Mstatic] = vec2featmat(config.melbands, config.cepOrder);
|
dan@0
|
14 mfcc_static = Mstatic*logmel_feat;
|
dan@0
|
15 mfcc_d_dd = MM*stacklp(logmel_feat,4);
|
dan@0
|
16
|
dan@0
|
17 %Features
|
dan@0
|
18 features.mel_feat=mel_feat;
|
dan@0
|
19 features.logmel_feat=logmel_feat;
|
dan@0
|
20 features.mfcc_static=mfcc_static;
|
dan@0
|
21 features.mfcc_d_dd=mfcc_d_dd;
|
dan@0
|
22
|
dan@0
|
23 % Standard no segmentation and threholding
|
dan@0
|
24 indicesEvent = [1:size(mel_feat,2)];
|
dan@0
|
25 indicesSilence = [];
|
dan@0
|
26 indicesAboveThreshold = [1:size(mel_feat,2)];
|
dan@0
|
27 indicesBelowThreshold = [];
|
dan@0
|
28
|
dan@0
|
29 %Do a segmentation
|
dan@0
|
30 if (~isempty(startStop))
|
dan@0
|
31 %Determine start and stop frame
|
dan@0
|
32 startFrame = 1 + floor((startStop(1)/(config.framestep_ms/1000)));
|
dan@0
|
33 stopFrame = startFrame + ceil((startStop(2)-startStop(1))/(config.framestep_ms/1000));
|
dan@0
|
34 if(stopFrame > size(mel_feat,2)),stopFrame = size(mel_feat,2); end,
|
dan@0
|
35 %These frame indices correspond to the event
|
dan@0
|
36 indicesEvent = [startFrame : stopFrame];
|
dan@0
|
37 %These frame indices correspond to the silence
|
dan@0
|
38 indicesSilence = [1:startFrame-1 stopFrame+1:size(mel_feat,2)];
|
dan@0
|
39 %Take only those event frames where C0 > minC0
|
dan@0
|
40 %Take only those silence frames where C0 <= minC0
|
dan@0
|
41 if (~isempty(minC0))
|
dan@0
|
42 indicesAboveThreshold=find(mfcc_static(end,:)>minC0);
|
dan@0
|
43 indicesBelowThreshold=find(mfcc_static(end,:)<minC0);
|
dan@0
|
44 end,
|
dan@0
|
45 end,
|
dan@0
|
46 features.indicesEvent=indicesEvent;
|
dan@0
|
47 features.indicesSilence=indicesSilence;
|
dan@0
|
48 features.indicesAboveThreshold=indicesAboveThreshold;
|
dan@0
|
49 features.indicesBelowThreshold=indicesBelowThreshold;
|
dan@0
|
50 end
|
dan@0
|
51
|