dan@0: function [features] = feature_extraction(segment,config,startStop,minC0) dan@0: %% dan@0: % Mobilab 2012-2013 dan@0: % dan@0: %% dan@0: if nargin < 4, minC0 = []; end, %minC0 will be placed empty dan@0: %if nargin < 3, startStop = [0 size(segment,1)/config.fs]; end, %Default no segmentation dan@0: if nargin < 3, startStop = []; end, %startSop is left empty, no segmentation occurs dan@0: %% dan@0: % Calculate the features dan@0: mel_feat = FE(segment, config); dan@0: logmel_feat = log(mel_feat); dan@0: [MM,Mstatic] = vec2featmat(config.melbands, config.cepOrder); dan@0: mfcc_static = Mstatic*logmel_feat; dan@0: mfcc_d_dd = MM*stacklp(logmel_feat,4); dan@0: dan@0: %Features dan@0: features.mel_feat=mel_feat; dan@0: features.logmel_feat=logmel_feat; dan@0: features.mfcc_static=mfcc_static; dan@0: features.mfcc_d_dd=mfcc_d_dd; dan@0: dan@0: % Standard no segmentation and threholding dan@0: indicesEvent = [1:size(mel_feat,2)]; dan@0: indicesSilence = []; dan@0: indicesAboveThreshold = [1:size(mel_feat,2)]; dan@0: indicesBelowThreshold = []; dan@0: dan@0: %Do a segmentation dan@0: if (~isempty(startStop)) dan@0: %Determine start and stop frame dan@0: startFrame = 1 + floor((startStop(1)/(config.framestep_ms/1000))); dan@0: stopFrame = startFrame + ceil((startStop(2)-startStop(1))/(config.framestep_ms/1000)); dan@0: if(stopFrame > size(mel_feat,2)),stopFrame = size(mel_feat,2); end, dan@0: %These frame indices correspond to the event dan@0: indicesEvent = [startFrame : stopFrame]; dan@0: %These frame indices correspond to the silence dan@0: indicesSilence = [1:startFrame-1 stopFrame+1:size(mel_feat,2)]; dan@0: %Take only those event frames where C0 > minC0 dan@0: %Take only those silence frames where C0 <= minC0 dan@0: if (~isempty(minC0)) dan@0: indicesAboveThreshold=find(mfcc_static(end,:)>minC0); dan@0: indicesBelowThreshold=find(mfcc_static(end,:)