diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Code/Collation/get_HNR.m	Wed Feb 13 11:02:39 2013 +0000
@@ -0,0 +1,61 @@
+function [] = get_HNR( dirName, statsFileID )
+
+DEBUG=1;
+% this function collates the results of all HNR values
+
+% identify the speaker in the stats file
+fprintf( statsFileID, '%s ', dirName );
+
+metricName = '_HNR';
+metricFileName = [ dirName metricName '.txt'];
+metrics = readValuesFromFile( statsFileID, metricFileName, metricName );
+
+if(DEBUG)
+    subplot(211);
+    if( strfind( dirName, 'neg') )
+        plot(metrics, 'b'); hold on;
+    elseif( strfind( dirName, 'pos') )
+        plot(metrics, 'r'); hold on;
+    end
+end
+
+% get basic metric set
+[ basicSet ] = basicMetricSet( metrics, statsFileID );
+
+
+if(DEBUG)
+    subplot(212); 
+    if( strfind( dirName, 'neg') )
+        plot(basicSet, 'xb'); hold on;
+    elseif( strfind( dirName, 'pos') )
+        plot(basicSet, 'xr'); hold on;
+    end
+end
+
+% calculate the ratio of voiced (HNR > 0) to unvoiced frames (HNR <= 0)
+noOfUnvoicedFrames = length( find( metrics <= 0 ));
+noOfVoicedFrames = length( find( metrics > 0 ));
+unvoicedToVoicedRatio = ( noOfUnvoicedFrames / noOfVoicedFrames );
+fprintf( statsFileID, '\t %f ', unvoicedToVoicedRatio);
+
+% calculate the average duration of the voiced and unvoiced periods
+
+tsig = ( metrics > 0);
+dsig = diff([1 tsig' 1]);
+startIndex = find(dsig < 0);
+endIndex = find(dsig > 0)-1;
+unvoicedDuration = endIndex-startIndex+1;
+meanUnvoicedDuration = mean( unvoicedDuration )
+fprintf( statsFileID, '\t %f ', meanUnvoicedDuration);
+
+
+startIndex = find(dsig > 0);
+startIndex = startIndex(1:end-1);
+endIndex = find(dsig < 0)-1;
+endIndex = endIndex(2:end);
+voicedDuration = endIndex-startIndex+1;
+meanVoicedDuration = mean( voicedDuration )
+fprintf( statsFileID, '\t %f ', meanVoicedDuration);
+
+
+fprintf( statsFileID, '\n');
\ No newline at end of file