comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:ea0c737c6323
1 function [ silenceSegments ] = detect_Silence( currentSampleName, OVERWRITE );
2
3 %returns an array containing the start and end frames for non-silent segments
4
5 % open original silence calculation
6 fileName = [ currentSampleName '_silence.txt'];
7 % read pitch metrics from file
8 fileID = fopen( fileName );
9
10 if( (fileID <= 0) || (OVERWRITE) ) %does the file exist?
11 % no
12 disp('WARNING: MISSING SILENCE FILE');
13 %calculate it
14 [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] );
15 limits = calculate_Silence( x, fs, frameLength );
16 % create voicing metrics file
17 fileID = fopen( fileName, 'w');
18 fprintf( fileID, 'non-silent start frame \t non-silent end frame \n ');
19 rowNum = size(limits);
20 rowNum = rowNum(1);
21 if( rowNum == 0 )
22 % there are no silent frames
23 fprintf( fileID, '%d \t %d \n', 0, 0 );
24 end
25 for i=1:rowNum
26 fprintf( fileID, '%d \t %d \n', limits(i,1), limits(i,2) );
27 end
28 fclose( fileID );
29 fileID = fopen( fileName );
30 end
31 %
32 % strip off header
33 junk = fscanf( fileID, '%s', 6 );
34 silence = fscanf( fileID, '%d', inf );
35 silenceSegments = [silence(1:2:end) silence(2:2:end)];
36 fclose( fileID );
37