Mercurial > hg > emotion-detection-top-level
diff Code/Descriptors/Matlab/Speech/detect_MFCC.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Descriptors/Matlab/Speech/detect_MFCC.m Wed Feb 13 11:02:39 2013 +0000 @@ -0,0 +1,44 @@ +function [HNR] = detect_MFCC( sampleWavFileName, OVERWRITE ) + +sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); +[x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); + +%---------------- GET THE SILENT FRAME VALUES ------------------- + +% only wish to consider pitch values from voiced frames. +% silent and unvoiced frames will produce pitch values that +% are random and therefore will bias our results + +segmentFrames = detect_Silence( sampleWavFileName, 0 ); +[ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); + +% open original calculation +fileName = [ sampleFileName '_MFCC.txt']; +fileID = fopen( fileName ); + +if(( fileID <= 0 ) || ( OVERWRITE )) %does the file exist? + % no + disp('WARNING: MISSING MFCC FILE'); + %calculate it + mfcc = calculate_MFCC( x, fs, frameLength, noOfFrames ); + + fileID = fopen( fileName, 'w'); + for i = 1 : (noOfFrames-1) + if( silentFrames(i) == 1 ) + % frame is not silent + fprintf(fileID, '%d %s \n' , i, num2str( mfcc(:,i)' )); + else + % set to zero + mfcc(:,i) = 0; + end + end + fclose( fileID ); + fileID = fopen( fileName ); +end + + +mfcc = fscanf( fileID, '%f', inf ); +mfcc = buffer(mfcc,14); % 13 MFCC values and one frame number +mfcc = mfcc(2:14,:)'; + +fclose(fileID);