view Code/Descriptors/Matlab/Common/removeSilentData.m @ 2:5fd388fdd6ef

initial commit - this file allows the programmer to select which of the PRAAT generated metrics the user wishes to use for classification, and then applies the k-means classifier.
author Dawn Black <dawn.black@eecs.qmul.ac.uk>
date Mon, 10 Sep 2012 09:18:15 +0100
parents ea0c737c6323
children
line wrap: on
line source
function [ silentFrames ] = removeSilentData( silentSegments, noOfFrames )

%---------------- GET THE SILENT FRAME VALUES -------------------
% only wish to consider values from voiced frames.
% silent frames will produce data values that
% are random and therefore will bias our results
% returns an array of values where '1' indicates a non-silent frame

    silentFrames = zeros(1,noOfFrames);
    [m n] = size(silentSegments);
    if(  silentSegments(1,1) == 0 && silentSegments(1,2) == 0 )
        % we have only one segment - the entire file
        silentSegments(1,1) = 1;
        silentSegments(1,2) = floor(length(x)/frameLength);
        [m n] = size(silentSegments);
    end
    
    % check for start at sample 0
    if( silentSegments(1,1) == 0)
        silentSegments(1,1) = 1;
    end
    
    for i=1:m
        start = silentSegments(i,1);
        stop = silentSegments(i,2);
        if( stop > noOfFrames )
            stop = noOfFrames;
            silentSegments(i,2) = noOfFrames;
        end
            
        if( start == 0 ) 
            start = 1;
        end
        
        
        silentFrames( start : stop ) = 1;
    end
    
end