Mercurial > hg > emotion-detection-top-level
comparison Code/Collation/get_Pitch.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_Pitch( 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 = '_YIN_pitch'; | |
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 metrics = metrics( voicedFrames ); | |
58 | |
59 | |
60 if(DEBUG) | |
61 subplot(211);hold on; | |
62 if( strfind( dirName, 'neg') ) | |
63 plot(metrics,'b'); | |
64 elseif( strfind( dirName, 'pos') ) | |
65 plot(metrics,'r'); | |
66 end | |
67 end | |
68 | |
69 % get basic metric set | |
70 [ metricSet ] = basicMetricSet( metrics, statsFileID ); | |
71 | |
72 if(DEBUG) | |
73 subplot(212); | |
74 if( strfind( dirName, 'neg') ) | |
75 plot(metrics, 'xb'); hold on; | |
76 elseif( strfind( dirName, 'pos') ) | |
77 plot(metrics, 'xr'); hold on; | |
78 end | |
79 end | |
80 | |
81 | |
82 % get basic metric set for the first derivative | |
83 firstDerivative = gradient( metrics ); | |
84 [ firstDerivativeMetricSet ] = basicMetricSet( firstDerivative, statsFileID ); | |
85 | |
86 % get basic metric set for the second derivative | |
87 secondDerivative = gradient( firstDerivative ); | |
88 [ secondDerivativeMetricSet ] = basicMetricSet( secondDerivative, statsFileID ); | |
89 | |
90 fprintf( statsFileID, '\n'); |