Mercurial > hg > emotion-detection-top-level
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:e1cfa7765647 | 4:92ca03a8fa99 |
---|---|
1 function [HNR] = detect_MFCC( sampleWavFileName, OVERWRITE ) | |
2 | |
3 sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 ); | |
4 [x, fs, frameLength, noOfFrames] = openFile( sampleWavFileName ); | |
5 | |
6 %---------------- GET THE SILENT FRAME VALUES ------------------- | |
7 | |
8 % only wish to consider pitch values from voiced frames. | |
9 % silent and unvoiced frames will produce pitch values that | |
10 % are random and therefore will bias our results | |
11 | |
12 segmentFrames = detect_Silence( sampleWavFileName, 0 ); | |
13 [ silentFrames ] = getSilentDataArray( segmentFrames, noOfFrames ); | |
14 | |
15 % open original calculation | |
16 fileName = [ sampleFileName '_MFCC.txt']; | |
17 fileID = fopen( fileName ); | |
18 | |
19 if(( fileID <= 0 ) || ( OVERWRITE )) %does the file exist? | |
20 % no | |
21 disp('WARNING: MISSING MFCC FILE'); | |
22 %calculate it | |
23 mfcc = calculate_MFCC( x, fs, frameLength, noOfFrames ); | |
24 | |
25 fileID = fopen( fileName, 'w'); | |
26 for i = 1 : (noOfFrames-1) | |
27 if( silentFrames(i) == 1 ) | |
28 % frame is not silent | |
29 fprintf(fileID, '%d %s \n' , i, num2str( mfcc(:,i)' )); | |
30 else | |
31 % set to zero | |
32 mfcc(:,i) = 0; | |
33 end | |
34 end | |
35 fclose( fileID ); | |
36 fileID = fopen( fileName ); | |
37 end | |
38 | |
39 | |
40 mfcc = fscanf( fileID, '%f', inf ); | |
41 mfcc = buffer(mfcc,14); % 13 MFCC values and one frame number | |
42 mfcc = mfcc(2:14,:)'; | |
43 | |
44 fclose(fileID); |