Mercurial > hg > emotion-detection-top-level
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ea0c737c6323 |
---|---|
1 function [] = checkVUV() | |
2 | |
3 sampleName = '01_a_male01_pos'; | |
4 [x, fs, frameLength, noOfFrames] = openFile( [sampleName '.wav'] ); | |
5 y = buffer( x, frameLength ); | |
6 | |
7 %---------------- GET THE SILENT FRAME VALUES ------------------- | |
8 | |
9 % only wish to consider pitch values from voiced frames. | |
10 % silent and unvoiced frames will produce pitch values that | |
11 % are random and therefore will bias our results | |
12 segmentFrames = getSilenceDecision( sampleName ); | |
13 [ silentFrames ] = removeSilentData( segmentFrames, noOfFrames ); | |
14 | |
15 | |
16 % % open original annotation file | |
17 % fileName = [sampleName '.txt']; | |
18 % % read metrics from file | |
19 % fileID = fopen( fileName ); | |
20 % data = fscanf( fileID, '%d', inf ); | |
21 % annotatedPitch = data(3:4:end); | |
22 % fclose( fileID ); | |
23 | |
24 % open HNR file | |
25 fileName = [sampleName '_HNR.txt']; | |
26 % read metrics from file | |
27 fileID = fopen( fileName ); | |
28 data = fscanf( fileID, '%f', inf ); | |
29 harmonic2noise = data(2:2:end); | |
30 fclose( fileID ); | |
31 | |
32 largestH2NValue = max( [max(harmonic2noise) abs(min(harmonic2noise))] ); | |
33 %normalise | |
34 harmonic2noise = harmonic2noise/largestH2NValue; | |
35 %round to 1dp | |
36 harmonic2noise= (round(harmonic2noise*10))/10; | |
37 | |
38 % open audio power file | |
39 fileName = [sampleName '_AP.txt']; | |
40 % read metrics from file | |
41 fileID = fopen( fileName ); | |
42 data = fscanf( fileID, '%f', inf ); | |
43 audioPower = data(2:2:end); | |
44 fclose( fileID ); | |
45 maxPower = max(audioPower); | |
46 | |
47 | |
48 minFreq = ceil(fs/getVariables('getMinFreq')); %default minimum fundatmental frequency | |
49 maxFreq = ceil(fs/getVariables('getMaxFreq')); %default maximum fundamental frequency | |
50 | |
51 % open pitch file | |
52 fileName = [sampleName '_YIN_pitch.txt']; | |
53 % read metrics from file | |
54 fileID = fopen( fileName ); | |
55 data = fscanf( fileID, '%f', inf ); | |
56 pitch = data(2:2:end); | |
57 fclose( fileID ); | |
58 | |
59 % open band power file | |
60 % fileName = [sampleName '_ASBP_norm.txt']; | |
61 % % read metrics from file | |
62 % fileID = fopen( fileName ); | |
63 % data = fscanf( fileID, '%f', inf ); | |
64 % bandPowerRatio = data(2:2:end); | |
65 % fclose( fileID ); | |
66 % bandPowerRatioRMS = sqrt( mean(( bandPowerRatio/max(bandPowerRatio) ).^2 )); | |
67 % | |
68 | |
69 | |
70 HNRThresh = 0; | |
71 hold off; | |
72 minLength = min([length(harmonic2noise) length(audioPower) length(pitch)]); | |
73 plotUnits = 1/frameLength; | |
74 for( i=1:minLength ) | |
75 | |
76 | |
77 if( silentFrames(i) == 0 ) % harmonic2noise(i) == 0 ) | |
78 %silent | |
79 % plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'y' );hold on; | |
80 plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'y' );hold on; | |
81 vuv(i) = 0; | |
82 elseif( ((harmonic2noise(i) <= HNRThresh))... %|| (bandPowerRatio(i)/max(bandPowerRatio) < 0.001)) ... | |
83 || (pitch(i) > minFreq) ... | |
84 || (pitch(i) < maxFreq)) %... | |
85 % || (audioPower(i)/maxPower < 0.0005)) | |
86 % unvoiced | |
87 % plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'r' );hold on; | |
88 plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'r' );hold on; | |
89 vuv(i) = 2; | |
90 else | |
91 %voiced | |
92 % plot( ((i-1)*frameLength)+1:(i*frameLength), y(:,i), 'g' );hold on; | |
93 plot( i-0.5 + plotUnits : plotUnits : i+0.5, y(:,i), 'g' );hold on; | |
94 vuv(i) = 1; | |
95 end | |
96 end | |
97 | |
98 | |
99 % plot( 1 : 1 : length(harmonic2noise), harmonic2noise, 'b' );hold on; | |
100 % plot( 1 : 1 : length(pitch), pitch/max(pitch), 'w' );hold on; | |
101 % % pitch thresholds | |
102 % L=line([0 noOfFrames], [maxFreq/max(pitch) maxFreq/max(pitch)]); | |
103 % set(L,'color',[1 0 0]); | |
104 % L=line([0 noOfFrames], [minFreq/max(pitch) minFreq/max(pitch)]); | |
105 % set(L,'color',[1 0 0]); | |
106 % | |
107 % %HNR threshold | |
108 % L=line([0 noOfFrames], [HNRThresh HNRThresh]); | |
109 % set(L, 'color', [0 0 1] ); |