view Code/Descriptors/Matlab/Common/detect_Silence.m @ 4:92ca03a8fa99 tip

Update to ICASSP 2013 benchmark
author Dawn Black
date Wed, 13 Feb 2013 11:02:39 +0000
parents ea0c737c6323
children
line wrap: on
line source
function [ silenceSegments ] = detect_Silence( sampleWavFileName, OVERWRITE );

%returns an array containing the start and end frames for non-silent segments

% open original silence calculation
sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 );
fileName = [ sampleFileName '_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(  sampleWavFileName ); 
    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 );