Mercurial > hg > emotion-detection-top-level
view Code/Descriptors/Matlab/Common/detect_Silence.m @ 0:ea0c737c6323
first commit
author | Dawn Black <dawn.black@eecs.qmul.ac.uk> |
---|---|
date | Thu, 26 Jul 2012 14:46:25 +0100 |
parents | |
children | 92ca03a8fa99 |
line wrap: on
line source
function [ silenceSegments ] = detect_Silence( currentSampleName, OVERWRITE ); %returns an array containing the start and end frames for non-silent segments % open original silence calculation fileName = [ currentSampleName '_silence.txt']; % read pitch metrics from file fileID = fopen( fileName ); if( (fileID <= 0) || (OVERWRITE) ) %does the file exist? % no disp('WARNING: MISSING SILENCE FILE'); %calculate it [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] ); limits = calculate_Silence( x, fs, frameLength ); % create voicing metrics file fileID = fopen( fileName, 'w'); fprintf( fileID, 'non-silent start frame \t non-silent end frame \n '); rowNum = size(limits); rowNum = rowNum(1); if( rowNum == 0 ) % there are no silent frames fprintf( fileID, '%d \t %d \n', 0, 0 ); end for i=1:rowNum fprintf( fileID, '%d \t %d \n', limits(i,1), limits(i,2) ); end fclose( fileID ); fileID = fopen( fileName ); end % % strip off header junk = fscanf( fileID, '%s', 6 ); silence = fscanf( fileID, '%d', inf ); silenceSegments = [silence(1:2:end) silence(2:2:end)]; fclose( fileID );