Mercurial > hg > emotion-detection-top-level
diff Code/Test/checkVUV.m @ 0:ea0c737c6323
first commit
| author | Dawn Black <dawn.black@eecs.qmul.ac.uk> |
|---|---|
| date | Thu, 26 Jul 2012 14:46:25 +0100 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/Test/checkVUV.m Thu Jul 26 14:46:25 2012 +0100 @@ -0,0 +1,109 @@ +function [] = checkVUV() + +sampleName = '01_a_male01_pos'; +[x, fs, frameLength, noOfFrames] = openFile( [sampleName '.wav'] ); +y = buffer( x, frameLength ); + + %---------------- GET THE SILENT FRAME VALUES ------------------- + +% only wish to consider pitch values from voiced frames. +% silent and unvoiced frames will produce pitch values that +% are random and therefore will bias our results +segmentFrames = getSilenceDecision( sampleName ); +[ silentFrames ] = removeSilentData( segmentFrames, noOfFrames ); + + +% % open original annotation file +% fileName = [sampleName '.txt']; +% % read metrics from file +% fileID = fopen( fileName ); +% data = fscanf( fileID, '%d', inf ); +% annotatedPitch = data(3:4:end); +% fclose( fileID ); + +% open HNR file +fileName = [sampleName '_HNR.txt']; +% read metrics from file +fileID = fopen( fileName ); +data = fscanf( fileID, '%f', inf ); +harmonic2noise = data(2:2:end); +fclose( fileID ); + +largestH2NValue = max( [max(harmonic2noise) abs(min(harmonic2noise))] ); +%normalise +harmonic2noise = harmonic2noise/largestH2NValue; +%round to 1dp +harmonic2noise= (round(harmonic2noise*10))/10; + +% open audio power file +fileName = [sampleName '_AP.txt']; +% read metrics from file +fileID = fopen( fileName ); +data = fscanf( fileID, '%f', inf ); +audioPower = data(2:2:end); +fclose( fileID ); +maxPower = max(audioPower); + + +minFreq = ceil(fs/getVariables('getMinFreq')); %default minimum fundatmental frequency +maxFreq = ceil(fs/getVariables('getMaxFreq')); %default maximum fundamental frequency + +% open pitch file +fileName = [sampleName '_YIN_pitch.txt']; +% read metrics from file +fileID = fopen( fileName ); +data = fscanf( fileID, '%f', inf ); +pitch = data(2:2:end); +fclose( fileID ); + +% open band power file +% fileName = [sampleName '_ASBP_norm.txt']; +% % read metrics from file +% fileID = fopen( fileName ); +% data = fscanf( fileID, '%f', inf ); +% bandPowerRatio = data(2:2:end); +% fclose( fileID ); +% bandPowerRatioRMS = sqrt( mean(( bandPowerRatio/max(bandPowerRatio) ).^2 )); +% + + +HNRThresh = 0; +hold off; +minLength = min([length(harmonic2noise) length(audioPower) length(pitch)]); +plotUnits = 1/frameLength; +for( i=1:minLength ) + + + if( silentFrames(i) == 0 ) % harmonic2noise(i) == 0 ) + %silent +% plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'y' );hold on; + plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'y' );hold on; + vuv(i) = 0; + elseif( ((harmonic2noise(i) <= HNRThresh))... %|| (bandPowerRatio(i)/max(bandPowerRatio) < 0.001)) ... + || (pitch(i) > minFreq) ... + || (pitch(i) < maxFreq)) %... +% || (audioPower(i)/maxPower < 0.0005)) + % unvoiced +% plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'r' );hold on; + plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'r' );hold on; + vuv(i) = 2; + else + %voiced +% plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'g' );hold on; + plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'g' );hold on; + vuv(i) = 1; + end +end + + +% plot( 1 : 1 : length(harmonic2noise), harmonic2noise, 'b' );hold on; +% plot( 1 : 1 : length(pitch), pitch/max(pitch), 'w' );hold on; +% % pitch thresholds +% L=line([0 noOfFrames], [maxFreq/max(pitch) maxFreq/max(pitch)]); +% set(L,'color',[1 0 0]); +% L=line([0 noOfFrames], [minFreq/max(pitch) minFreq/max(pitch)]); +% set(L,'color',[1 0 0]); +% +% %HNR threshold +% L=line([0 noOfFrames], [HNRThresh HNRThresh]); +% set(L, 'color', [0 0 1] );
