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