Dawn@4: function [HNR] = detect_MFCC( sampleWavFileName, OVERWRITE ) Dawn@4: Dawn@4: sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); Dawn@4: [x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); Dawn@4: Dawn@4: %---------------- GET THE SILENT FRAME VALUES ------------------- Dawn@4: Dawn@4: % only wish to consider pitch values from voiced frames. Dawn@4: % silent and unvoiced frames will produce pitch values that Dawn@4: % are random and therefore will bias our results Dawn@4: Dawn@4: segmentFrames = detect_Silence( sampleWavFileName, 0 ); Dawn@4: [ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); Dawn@4: Dawn@4: % open original calculation Dawn@4: fileName = [ sampleFileName '_MFCC.txt']; Dawn@4: fileID = fopen( fileName ); Dawn@4: Dawn@4: if(( fileID <= 0 ) || ( OVERWRITE )) %does the file exist? Dawn@4: % no Dawn@4: disp('WARNING: MISSING MFCC FILE'); Dawn@4: %calculate it Dawn@4: mfcc = calculate_MFCC( x, fs, frameLength, noOfFrames ); Dawn@4: Dawn@4: fileID = fopen( fileName, 'w'); Dawn@4: for i = 1 : (noOfFrames-1) Dawn@4: if( silentFrames(i) == 1 ) Dawn@4: % frame is not silent Dawn@4: fprintf(fileID, '%d %s \n' , i, num2str( mfcc(:,i)' )); Dawn@4: else Dawn@4: % set to zero Dawn@4: mfcc(:,i) = 0; Dawn@4: end Dawn@4: end Dawn@4: fclose( fileID ); Dawn@4: fileID = fopen( fileName ); Dawn@4: end Dawn@4: Dawn@4: Dawn@4: mfcc = fscanf( fileID, '%f', inf ); Dawn@4: mfcc = buffer(mfcc,14); % 13 MFCC values and one frame number Dawn@4: mfcc = mfcc(2:14,:)'; Dawn@4: Dawn@4: fclose(fileID);