Mercurial > hg > emotion-detection-top-level
comparison Code/Collation/get_AudioPower.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 [] = get_AudioPower( dirName, statsFileID ) | |
2 | |
3 DEBUG=0; | |
4 % this function collates the results of all HNR values | |
5 | |
6 % identify the speaker in the stats file | |
7 fprintf( statsFileID, '%s ', dirName ); | |
8 | |
9 metricName = '_AP'; | |
10 metricFileName = [ dirName metricName '.txt']; | |
11 [ metrics, nanValues ] = readValuesFromFile( statsFileID, metricFileName, metricName ); | |
12 | |
13 %---------------- GET THE VOICED FRAME VALUES ------------------- | |
14 | |
15 % only wish to consider values from voiced frames. | |
16 | |
17 % going to disregard all unvoiced frames as these produce outliers | |
18 [vuv] = detect_VoicedUnvoiced( [ dirName '.wav' ], 0 ); | |
19 % if vuv is longer than the pitch array, truncate. | |
20 if( length(vuv) ~= length(nanValues) ) | |
21 if( (length(vuv) - length(nanValues)) > 1 ) | |
22 disp('EEEK!'); | |
23 end | |
24 if( length(vuv) > length(nanValues) ) | |
25 %increase metrics | |
26 nanValues = [ nanValues; 0 ]; | |
27 else | |
28 vuv = [vuv; 0]; | |
29 end | |
30 end | |
31 | |
32 | |
33 % % remove any NaN pitch values from the voicing information | |
34 % i=1; | |
35 % while( i <= length(vuv) ) | |
36 % | |
37 % if( nanValues(i) == 1 ) | |
38 % if( i == 1 ) | |
39 % vuv = vuv(2:length(vuv)); | |
40 % nanValues = nanValues(2:length(nanValues)); | |
41 % elseif(i == length(vuv) ) | |
42 % vuv = vuv(1:length(vuv)-1); | |
43 % nanValues = nanValues(1:length(nanValues)-1); | |
44 % else | |
45 % vuv = [ vuv(1: i-1); vuv(i+1:end) ]; | |
46 % nanValues = [ nanValues(1: i-1); nanValues(i+1:end) ]; | |
47 % end | |
48 % else | |
49 % i=i+1; | |
50 % end | |
51 % | |
52 % end | |
53 | |
54 % remove the non-voiced frames (includes unvoiced and silent frames) from the metrics | |
55 | |
56 voicedFrames = find( vuv == 1 ); | |
57 unvoicedFrames = find( vuv == 2 ); | |
58 | |
59 % find the average energies for voiced and unvoiced speech | |
60 voicedEnergy = sum( metrics( voicedFrames )) / length( voicedFrames ); | |
61 unvoicedEnergy = sum( metrics( unvoicedFrames )) / length( unvoicedFrames ); | |
62 | |
63 metrics = metrics( voicedFrames ); | |
64 | |
65 | |
66 if(DEBUG) | |
67 subplot(211);hold on; | |
68 if( strfind( dirName, 'neg') ) | |
69 plot(metrics,'b'); | |
70 elseif( strfind( dirName, 'pos') ) | |
71 plot(metrics,'r'); | |
72 end | |
73 end | |
74 | |
75 % get basic metric set | |
76 [ metricSet ] = basicMetricSet( metrics, statsFileID ); | |
77 | |
78 if(DEBUG) | |
79 subplot(212); | |
80 if( strfind( dirName, 'neg') ) | |
81 plot(metrics, 'xb'); hold on; | |
82 elseif( strfind( dirName, 'pos') ) | |
83 plot(metrics, 'xr'); hold on; | |
84 end | |
85 end | |
86 | |
87 | |
88 % get basic metric set for the first derivative | |
89 firstDerivative = gradient( metrics ); | |
90 [ firstDerivativeMetricSet ] = basicMetricSet( firstDerivative, statsFileID ); | |
91 | |
92 % print the average voiced and unvoiced energy to file | |
93 fprintf( statsFileID, '\t %f \t %f ', voicedEnergy, unvoicedEnergy); | |
94 | |
95 fprintf( statsFileID, '\n'); |