Dawn@4
|
1 function [] = get_MFCCS( dirName, statsFileID )
|
Dawn@4
|
2
|
Dawn@4
|
3
|
Dawn@4
|
4 % this function collates the results of all values calculated for the
|
Dawn@4
|
5 % MFCCs
|
Dawn@4
|
6
|
Dawn@4
|
7 DEBUG=0;
|
Dawn@4
|
8
|
Dawn@4
|
9 % identify the speaker in the stats file
|
Dawn@4
|
10 fprintf( statsFileID, '%s ', dirName );
|
Dawn@4
|
11
|
Dawn@4
|
12 metricName = '_MFCC';
|
Dawn@4
|
13 metricFileName = [ dirName metricName '.txt'];
|
Dawn@4
|
14 numberOfValuesPerFrame = 13; % 13 MFCC's
|
Dawn@4
|
15
|
Dawn@4
|
16 FileID = fopen( metricFileName );
|
Dawn@4
|
17
|
Dawn@4
|
18 %---------------- GET THE VOICED FRAME VALUES -------------------
|
Dawn@4
|
19
|
Dawn@4
|
20 % only wish to consider values from voiced frames. The MFCCs were
|
Dawn@4
|
21 % calculate for only non-silent frames anyway, but now we need to
|
Dawn@4
|
22 % remove the unvoiced frame values
|
Dawn@4
|
23
|
Dawn@4
|
24 % going to disregard all unvoiced frames as these produce outliers
|
Dawn@4
|
25 [vuv] = detect_VoicedUnvoiced( [ dirName '.wav' ], 0 );
|
Dawn@4
|
26
|
Dawn@4
|
27 % get the silent frames
|
Dawn@4
|
28 segmentFrames = detect_Silence( [ dirName '.wav' ], 0 );
|
Dawn@4
|
29 [ silentFrames ] = getSilentDataArray( segmentFrames, length(vuv) );
|
Dawn@4
|
30
|
Dawn@4
|
31 % remove silent frames from vuv
|
Dawn@4
|
32 non_silentFrames = find(silentFrames == 1);
|
Dawn@4
|
33 vuv = vuv( non_silentFrames );
|
Dawn@4
|
34 % voicedFrames = find( vuv == 1 );
|
Dawn@4
|
35
|
Dawn@4
|
36 if( FileID <= 0 ) %does the file exist?
|
Dawn@4
|
37 % if not
|
Dawn@4
|
38 message = ['WARNING: MISSING ' metricName ' FILE'];
|
Dawn@4
|
39 disp( message );
|
Dawn@4
|
40 fprintf( statsFileID, ' \s missing', metricName );
|
Dawn@4
|
41
|
Dawn@4
|
42 else
|
Dawn@4
|
43 mfcc = readManyValuesFromFile( statsFileID, metricFileName, metricName, numberOfValuesPerFrame );
|
Dawn@4
|
44 % smooth to get rid of outliers
|
Dawn@4
|
45 % for( i=1:numberOfValuesPerFrame )
|
Dawn@4
|
46 % % smoothedMfcc(:,i) = smooth( mfcc( voicedFrames,i ) );
|
Dawn@4
|
47 % smoothedMfcc(:,i) = smooth( mfcc( :,i ) );
|
Dawn@4
|
48 % end
|
Dawn@4
|
49
|
Dawn@4
|
50 for( i=1:numberOfValuesPerFrame )
|
Dawn@4
|
51 % find the basic metric set for each frequency band
|
Dawn@4
|
52 % [ metrics(i,:) ] = basicMetricSet( smoothedMfcc(:,i), statsFileID );
|
Dawn@4
|
53 [ metrics(i,:) ] = basicMetricSet( mfcc(:,i), statsFileID );
|
Dawn@4
|
54 mean(i) = metrics(i,1);
|
Dawn@4
|
55 end
|
Dawn@4
|
56
|
Dawn@4
|
57 % find the gradient of each frequency band and its basic metric set
|
Dawn@4
|
58 [m,n]=size(metrics);
|
Dawn@4
|
59 for( i=1:numberOfValuesPerFrame )
|
Dawn@4
|
60 % gradSmoothedMfcc(:,i) = gradient( smoothedMfcc(:,i) );
|
Dawn@4
|
61 gradMfcc(:,i) = gradient( mfcc(:,i) );
|
Dawn@4
|
62 % [ metrics(i, n+1:2*n ) ] = basicMetricSet( gradSmoothedMfcc(:,i), statsFileID );
|
Dawn@4
|
63 [ metrics(i, n+1:2*n ) ] = basicMetricSet( gradMfcc(:,i), statsFileID );
|
Dawn@4
|
64 end
|
Dawn@4
|
65
|
Dawn@4
|
66 % calculate the basic metric set for the mean of all frequency
|
Dawn@4
|
67 % bands
|
Dawn@4
|
68 basicMetricSet( mean, statsFileID );
|
Dawn@4
|
69 end
|
Dawn@4
|
70
|
Dawn@4
|
71
|
Dawn@4
|
72 fprintf( statsFileID, '\n');
|
Dawn@4
|
73 fclose(FileID); |