Mercurial > hg > emotion-detection-top-level
comparison Code/Collation/get_HNR.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_HNR( dirName, statsFileID ) | |
2 | |
3 DEBUG=1; | |
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 = '_HNR'; | |
10 metricFileName = [ dirName metricName '.txt']; | |
11 metrics = readValuesFromFile( statsFileID, metricFileName, metricName ); | |
12 | |
13 if(DEBUG) | |
14 subplot(211); | |
15 if( strfind( dirName, 'neg') ) | |
16 plot(metrics, 'b'); hold on; | |
17 elseif( strfind( dirName, 'pos') ) | |
18 plot(metrics, 'r'); hold on; | |
19 end | |
20 end | |
21 | |
22 % get basic metric set | |
23 [ basicSet ] = basicMetricSet( metrics, statsFileID ); | |
24 | |
25 | |
26 if(DEBUG) | |
27 subplot(212); | |
28 if( strfind( dirName, 'neg') ) | |
29 plot(basicSet, 'xb'); hold on; | |
30 elseif( strfind( dirName, 'pos') ) | |
31 plot(basicSet, 'xr'); hold on; | |
32 end | |
33 end | |
34 | |
35 % calculate the ratio of voiced (HNR > 0) to unvoiced frames (HNR <= 0) | |
36 noOfUnvoicedFrames = length( find( metrics <= 0 )); | |
37 noOfVoicedFrames = length( find( metrics > 0 )); | |
38 unvoicedToVoicedRatio = ( noOfUnvoicedFrames / noOfVoicedFrames ); | |
39 fprintf( statsFileID, '\t %f ', unvoicedToVoicedRatio); | |
40 | |
41 % calculate the average duration of the voiced and unvoiced periods | |
42 | |
43 tsig = ( metrics > 0); | |
44 dsig = diff([1 tsig' 1]); | |
45 startIndex = find(dsig < 0); | |
46 endIndex = find(dsig > 0)-1; | |
47 unvoicedDuration = endIndex-startIndex+1; | |
48 meanUnvoicedDuration = mean( unvoicedDuration ) | |
49 fprintf( statsFileID, '\t %f ', meanUnvoicedDuration); | |
50 | |
51 | |
52 startIndex = find(dsig > 0); | |
53 startIndex = startIndex(1:end-1); | |
54 endIndex = find(dsig < 0)-1; | |
55 endIndex = endIndex(2:end); | |
56 voicedDuration = endIndex-startIndex+1; | |
57 meanVoicedDuration = mean( voicedDuration ) | |
58 fprintf( statsFileID, '\t %f ', meanVoicedDuration); | |
59 | |
60 | |
61 fprintf( statsFileID, '\n'); |