Dawn@4
|
1 function [] = kmeans_PRAAT_Singing( varargin )
|
dawn@2
|
2
|
dawn@2
|
3 cd 'C:\Users\dawn\Dropbox\TestResults'
|
dawn@2
|
4
|
Dawn@4
|
5 DEBUG = 0;
|
dawn@2
|
6 % output results file name
|
Dawn@4
|
7 masterFileOutputID = fopen( 'kmeans_Singing_PRAAT.txt', 'a' );
|
dawn@2
|
8 % input results file name
|
dawn@2
|
9 inputFileName = 'singingPRAATStats.txt';
|
dawn@2
|
10
|
dawn@2
|
11 % This function allows the user to stipulate which Singing voice LLD's they
|
dawn@2
|
12 % wish to forward to a k-means classifier and produces a file of
|
dawn@2
|
13 % performance characteristics. Input arguments stipulate the LLD's and
|
dawn@2
|
14 % there is a choice of:-
|
dawn@2
|
15 %
|
dawn@2
|
16 % ---- PRAAT JITTER MEASUREMENTS ----
|
dawn@2
|
17 % '_jitter_ddp'
|
dawn@2
|
18 % '_jitter_local'
|
dawn@2
|
19 % '_jitter_ppq5'
|
dawn@2
|
20 % '_jitter_rap'
|
dawn@2
|
21 % ---- PRAAT SHIMMER MEASUREMENTS ----
|
dawn@2
|
22 % '_shimmer_local'
|
dawn@2
|
23 % '_shimmer_dda'
|
dawn@2
|
24 % '_shimmer_apq3'
|
dawn@2
|
25 % '_shimmer_apq5'
|
dawn@2
|
26 % '_shimmer_apq11'
|
dawn@2
|
27 % ---- PRAAT FORMANT MEASUREMENTS ----
|
dawn@2
|
28 % '_Formant_Burg'
|
dawn@2
|
29 % '_Formant_all'
|
dawn@2
|
30 % '_Formant_robust'
|
dawn@2
|
31 %
|
dawn@2
|
32 % A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt
|
dawn@2
|
33 % is produced that contains the results of the k-mean classification for
|
dawn@2
|
34 % the LLD's specified and named in the result document title.
|
dawn@2
|
35
|
dawn@2
|
36 fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName);
|
dawn@2
|
37 inputFileID = fopen( inputFileName );
|
dawn@2
|
38
|
dawn@2
|
39 % get the column numbers of the results that we want to classify
|
dawn@2
|
40
|
dawn@2
|
41 % COLUMN NUMBER : METRIC
|
dawn@2
|
42 % 1 : audio file name
|
dawn@2
|
43 % 2 : jitter ddp
|
dawn@2
|
44 % 3 : jitter local
|
dawn@2
|
45 % 4 : jitter ppq5
|
dawn@2
|
46 % 5 : jitter rap
|
dawn@2
|
47 % 6 : shimmer local
|
dawn@2
|
48 % 7 : shimmer dda
|
dawn@2
|
49 % 8 : shimmer apq3
|
dawn@2
|
50 % 9 : shimmer apq5
|
dawn@2
|
51 % 10 : shimmer apq11
|
dawn@2
|
52 %
|
dawn@2
|
53 % ------------- BURG FORMANTS ---------------
|
dawn@2
|
54 % 11 : Number of BURG formants listed = nBF
|
dawn@2
|
55 %
|
dawn@2
|
56 % THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT
|
dawn@2
|
57 nMetrics = 24;
|
dawn@2
|
58 %
|
dawn@2
|
59 % 12 : mean frequency of the first BURG formant
|
dawn@2
|
60 % 13 : variance of the first BURG formant
|
dawn@2
|
61 % 14 : minimum frequency of the first BURG formant
|
dawn@2
|
62 % 15 : maximum frequency of the first BURG formant
|
dawn@2
|
63 % 16 : mean Frequency Derivative of the first BURG formant
|
dawn@2
|
64 % 17 : varience of the Frequency Derivative of the first BURG formant
|
dawn@2
|
65 % 18 : min of the Frequency Derivative of the first BURG formant
|
dawn@2
|
66 % 19 : max of the Frequency Derivative of the first BURG formant
|
dawn@2
|
67 % 20 : mean of the Frequency 2nd Derivative of the first BURG formant
|
dawn@2
|
68 % 21 : varience of the Frequency 2nd Derivative of the first BURG formant
|
dawn@2
|
69 % 22 : min of the Frequency 2nd Derivative of the first BURG formant
|
dawn@2
|
70 % 23 : max of the Frequency 2nd Derivative of the first BURG formant
|
dawn@2
|
71 % 24 : mean of the Bandwidth of the first BURG formant
|
dawn@2
|
72 % 25 : varience of the Bandwidth of the first BURG formant
|
dawn@2
|
73 % 26 : min of the Bandwidth of the first BURG formant
|
dawn@2
|
74 % 27 : max of the Bandwidth of the first BURG formant
|
dawn@2
|
75 % 28 : mean of the Bandwidth Derivative of the first BURG formant
|
dawn@2
|
76 % 29 : varience of the Bandwidth Derivative of the first BURG formant
|
dawn@2
|
77 % 30 : min of the Bandwidth Derivative of the first BURG formant
|
dawn@2
|
78 % 31 : max of the Bandwidth Derivative of the first BURG formant
|
dawn@2
|
79 % 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant
|
dawn@2
|
80 % 33 : var of the Bandwidth 2nd Derivative of the first BURG formant
|
dawn@2
|
81 % 34 : min of the Bandwidth 2nd Derivative of the first BURG formant
|
dawn@2
|
82 % 35 : max of the Bandwidth 2nd Derivative of the first BURG formant
|
dawn@2
|
83 %
|
dawn@2
|
84 % ....... there are nMetrics for each formant in nBF formants, so cycle
|
dawn@2
|
85 % through until the last is reached ......
|
dawn@2
|
86 %
|
dawn@2
|
87 % 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant
|
dawn@2
|
88 % 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant
|
dawn@2
|
89 % 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant
|
dawn@2
|
90 % 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant
|
dawn@2
|
91 % 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant
|
dawn@2
|
92 % 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant
|
dawn@2
|
93 % 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant
|
dawn@2
|
94 % 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant
|
dawn@2
|
95 % 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant
|
dawn@2
|
96 % 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant
|
dawn@2
|
97 % 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant
|
dawn@2
|
98 % 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant
|
dawn@2
|
99 % 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant
|
dawn@2
|
100 % 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant
|
dawn@2
|
101 % 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant
|
dawn@2
|
102 % 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant
|
dawn@2
|
103 % 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant
|
dawn@2
|
104 % 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant
|
dawn@2
|
105 % 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant
|
dawn@2
|
106 % 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant
|
dawn@2
|
107 % 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant
|
dawn@2
|
108 % 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant
|
dawn@2
|
109 % 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant
|
dawn@2
|
110 % 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant
|
dawn@2
|
111 %
|
dawn@2
|
112 % FOR THE MEAN OF ALL BURG FORMANTS
|
dawn@2
|
113 % 36 + (nBF*nMetrics) : mean of all formants Frequency
|
dawn@2
|
114 % 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
dawn@2
|
115 % 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
dawn@2
|
116 % 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
dawn@2
|
117 % 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
dawn@2
|
118 % 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
dawn@2
|
119 % 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
dawn@2
|
120 % 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
dawn@2
|
121 % 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
122 % 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
123 % 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
124 % 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
125 %
|
dawn@2
|
126 % ------------- ALL FORMANTS ---------------
|
dawn@2
|
127 %
|
dawn@2
|
128 % 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF
|
dawn@2
|
129 %
|
dawn@2
|
130 % startOfALLMeasurements = 36 + (nBF*nMetrics) + 13;
|
dawn@2
|
131 %
|
dawn@2
|
132 % startOfALLMeasurements : mean frequency of the first ALL formant
|
dawn@2
|
133 % startOfALLMeasurements + 1 : variance of the first ALL formant
|
dawn@2
|
134 % startOfALLMeasurements + 2 : minimum frequency of the first ALL formant
|
dawn@2
|
135 % startOfALLMeasurements + 3 : maximum frequency of the first ALL formant
|
dawn@2
|
136 % startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant
|
dawn@2
|
137 % startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant
|
dawn@2
|
138 % startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant
|
dawn@2
|
139 % startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant
|
dawn@2
|
140 % startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant
|
dawn@2
|
141 % startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant
|
dawn@2
|
142 % startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant
|
dawn@2
|
143 % startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant
|
dawn@2
|
144 % startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant
|
dawn@2
|
145 % startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant
|
dawn@2
|
146 % startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant
|
dawn@2
|
147 % startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant
|
dawn@2
|
148 % startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant
|
dawn@2
|
149 % startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant
|
dawn@2
|
150 % startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant
|
dawn@2
|
151 % startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant
|
dawn@2
|
152 % startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant
|
dawn@2
|
153 % startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant
|
dawn@2
|
154 % startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant
|
dawn@2
|
155 % startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant
|
dawn@2
|
156 %
|
dawn@2
|
157 % ....... there are nMetrics for each formant in nAF formants, so cycle
|
dawn@2
|
158 % through until the last is reached ......
|
dawn@2
|
159 %
|
dawn@2
|
160 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant
|
dawn@2
|
161 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant
|
dawn@2
|
162 % startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant
|
dawn@2
|
163 % startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant
|
dawn@2
|
164 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant
|
dawn@2
|
165 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant
|
dawn@2
|
166 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant
|
dawn@2
|
167 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant
|
dawn@2
|
168 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant
|
dawn@2
|
169 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant
|
dawn@2
|
170 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant
|
dawn@2
|
171 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant
|
dawn@2
|
172 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant
|
dawn@2
|
173 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant
|
dawn@2
|
174 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant
|
dawn@2
|
175 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant
|
dawn@2
|
176 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant
|
dawn@2
|
177 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant
|
dawn@2
|
178 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant
|
dawn@2
|
179 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant
|
dawn@2
|
180 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant
|
dawn@2
|
181 % startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant
|
dawn@2
|
182 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant
|
dawn@2
|
183 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant
|
dawn@2
|
184 %
|
dawn@2
|
185 % FOR THE MEAN OF ALL ALL FORMANTS
|
dawn@2
|
186 % startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency
|
dawn@2
|
187 % startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
dawn@2
|
188 % startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
dawn@2
|
189 % startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
dawn@2
|
190 % startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
dawn@2
|
191 % startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
dawn@2
|
192 % startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
dawn@2
|
193 % startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
dawn@2
|
194 % startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
195 % startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
196 % startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
197 % startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
198 %
|
dawn@2
|
199 % ------------- ROBUST FORMANTS ---------------
|
dawn@2
|
200 %
|
dawn@2
|
201 % startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF
|
dawn@2
|
202 %
|
dawn@2
|
203 % startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13;
|
dawn@2
|
204 %
|
dawn@2
|
205 % startOfROBUSTMeasurements : mean frequency of the first ROBUST formant
|
dawn@2
|
206 % startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant
|
dawn@2
|
207 % startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant
|
dawn@2
|
208 % startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant
|
dawn@2
|
209 % startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant
|
dawn@2
|
210 % startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant
|
dawn@2
|
211 % startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant
|
dawn@2
|
212 % startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant
|
dawn@2
|
213 % startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant
|
dawn@2
|
214 % startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant
|
dawn@2
|
215 % startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant
|
dawn@2
|
216 % startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant
|
dawn@2
|
217 % startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant
|
dawn@2
|
218 % startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant
|
dawn@2
|
219 % startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant
|
dawn@2
|
220 % startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant
|
dawn@2
|
221 % startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant
|
dawn@2
|
222 % startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant
|
dawn@2
|
223 % startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant
|
dawn@2
|
224 % startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant
|
dawn@2
|
225 % startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant
|
dawn@2
|
226 % startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant
|
dawn@2
|
227 % startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant
|
dawn@2
|
228 % startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant
|
dawn@2
|
229 %
|
dawn@2
|
230 % ....... there are nMetrics for each formant in nRF formants, so cycle
|
dawn@2
|
231 % through until the last is reached ......
|
dawn@2
|
232 %
|
dawn@2
|
233 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant
|
dawn@2
|
234 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant
|
dawn@2
|
235 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant
|
dawn@2
|
236 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant
|
dawn@2
|
237 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant
|
dawn@2
|
238 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant
|
dawn@2
|
239 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant
|
dawn@2
|
240 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant
|
dawn@2
|
241 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
242 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
243 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
244 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
245 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant
|
dawn@2
|
246 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant
|
dawn@2
|
247 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant
|
dawn@2
|
248 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant
|
dawn@2
|
249 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant
|
dawn@2
|
250 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant
|
dawn@2
|
251 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant
|
dawn@2
|
252 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant
|
dawn@2
|
253 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
254 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
255 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
256 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
dawn@2
|
257 %
|
dawn@2
|
258 % FOR THE MEAN OF ALL ROBUST FORMANTS
|
dawn@2
|
259 % startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency
|
dawn@2
|
260 % startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
dawn@2
|
261 % startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
dawn@2
|
262 % startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
dawn@2
|
263 % startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
dawn@2
|
264 % startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
dawn@2
|
265 % startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
dawn@2
|
266 % startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
dawn@2
|
267 % startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
268 % startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
269 % startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
270 % startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
dawn@2
|
271 %
|
dawn@2
|
272
|
dawn@2
|
273 noOfArguments = length(varargin);
|
dawn@2
|
274 columnIndices = [];
|
dawn@2
|
275
|
dawn@2
|
276 getBURGFormants = 0;
|
Dawn@4
|
277 getAllFormants=0;
|
dawn@2
|
278 getRobustFormants=0;
|
dawn@2
|
279
|
dawn@2
|
280 for i=1 : noOfArguments
|
dawn@2
|
281 if( strcmp( varargin{i}, 'jitter_ddp' ))
|
dawn@2
|
282 columnIndices = [columnIndices 1];
|
dawn@2
|
283 elseif( strcmp( varargin{i}, 'jitter_local' ))
|
dawn@2
|
284 columnIndices = [columnIndices 2];
|
dawn@2
|
285 elseif( strcmp( varargin{i}, 'jitter_ppq5' ))
|
dawn@2
|
286 columnIndices = [columnIndices 3];
|
dawn@2
|
287 elseif( strcmp( varargin{i}, 'jitter_rap' ))
|
dawn@2
|
288 columnIndices = [columnIndices 4];
|
dawn@2
|
289 elseif( strcmp( varargin{i}, 'shimmer_local' ))
|
dawn@2
|
290 columnIndices = [columnIndices 5];
|
dawn@2
|
291 elseif( strcmp( varargin{i}, 'shimmer_dda' ))
|
dawn@2
|
292 columnIndices = [columnIndices 6];
|
dawn@2
|
293 elseif( strcmp( varargin{i}, 'shimmer_apq3' ))
|
dawn@2
|
294 columnIndices = [columnIndices 7];
|
dawn@2
|
295 elseif( strcmp( varargin{i}, 'shimmer_apq5' ))
|
dawn@2
|
296 columnIndices = [columnIndices 8];
|
dawn@2
|
297 elseif( strcmp( varargin{i}, 'shimmer_apq11' ))
|
dawn@2
|
298 columnIndices = [columnIndices 9];
|
dawn@2
|
299 elseif( strcmp( varargin{i}, 'formant_Burg' ))
|
dawn@2
|
300 getBURGFormants = 1;
|
dawn@2
|
301 elseif( strcmp( varargin{i}, 'formant_all' ))
|
Dawn@4
|
302 getAllFormants=1;
|
dawn@2
|
303 elseif( strcmp( varargin{i}, 'formant_robust' ))
|
dawn@2
|
304 getRobustFormants=1;
|
dawn@2
|
305 end
|
dawn@2
|
306 end
|
dawn@2
|
307
|
dawn@2
|
308
|
Dawn@4
|
309 % outputFileName = 'individualResults/kmeans_Results_';
|
Dawn@4
|
310 % resultsFileName = 'kmeans_Results_';
|
dawn@2
|
311 titleName = '';
|
dawn@2
|
312 for i=1 : noOfArguments
|
dawn@2
|
313 % outputFileName = [ outputFileName varargin{i} '_'];
|
dawn@2
|
314 % resultsFileName = [ resultsFileName varargin{i} '_'];
|
dawn@2
|
315 titleName = [ titleName varargin{i} '_'];
|
dawn@2
|
316 fprintf( masterFileOutputID, '%s_', varargin{i} );
|
dawn@2
|
317 end
|
dawn@2
|
318
|
dawn@2
|
319 % titleName = outputFileName;
|
Dawn@4
|
320 % outputFileName = [ outputFileName titleName ];
|
Dawn@4
|
321 % resultsFileName = [ resultsFileName titleName ];
|
dawn@2
|
322
|
dawn@2
|
323 fprintf( masterFileOutputID, '\t' );
|
dawn@2
|
324
|
Dawn@4
|
325 % outputFileName = [ outputFileName '.txt'];
|
Dawn@4
|
326 % resultsFileName = [ resultsFileName '.txt'];
|
dawn@2
|
327
|
Dawn@4
|
328 % fileOutputID = fopen( outputFileName, 'w' );
|
Dawn@4
|
329 % fileKMeansOutputID = fopen( resultsFileName, 'w' );
|
dawn@2
|
330
|
dawn@2
|
331 % -------------------- get the data from the results file ---------------
|
dawn@2
|
332 lineCount = 0;
|
dawn@2
|
333 fileCount = 0;
|
dawn@2
|
334 data = [];
|
dawn@2
|
335 while( ~(feof(inputFileID)) )
|
dawn@2
|
336
|
dawn@2
|
337 outputValues = [];
|
dawn@2
|
338 % sampleEmotion = [];
|
dawn@2
|
339 % gender = [];
|
dawn@2
|
340
|
dawn@2
|
341 thestr = fgetl(inputFileID);
|
dawn@2
|
342 if( lineCount > 10 ) % skip the file header
|
dawn@2
|
343 fileCount = fileCount + 1;
|
dawn@2
|
344
|
dawn@2
|
345 % determine whether we have a positive or negative sample
|
dawn@2
|
346 sampleEmotion( fileCount ) = 'U';
|
dawn@2
|
347 if( ~(isempty(strfind(thestr,'pos'))))
|
dawn@2
|
348 % sample is positive
|
dawn@2
|
349 sampleEmotion( fileCount ) = 'P';
|
dawn@2
|
350 elseif( ~(isempty(strfind(thestr,'neg'))))
|
dawn@2
|
351 % sample is negative
|
dawn@2
|
352 sampleEmotion( fileCount ) = 'N';
|
dawn@2
|
353 else
|
dawn@2
|
354 disp('EEEK!');
|
dawn@2
|
355 pause;
|
dawn@2
|
356 end
|
dawn@2
|
357
|
dawn@2
|
358 % determine whether we have a male, female or trans sample
|
dawn@2
|
359 gender( fileCount ) = '?';
|
dawn@2
|
360 if( ~(isempty(strfind(thestr,'fem'))))
|
dawn@2
|
361 % gender is female
|
dawn@2
|
362 gender( fileCount ) = 'F';
|
dawn@2
|
363 elseif( ~(isempty(strfind(thestr,'male'))))
|
dawn@2
|
364 % gender is male
|
dawn@2
|
365 gender( fileCount ) = 'M';
|
dawn@2
|
366 elseif( ~(isempty(strfind(thestr,'trans'))))
|
dawn@2
|
367 % gender is trans
|
dawn@2
|
368 gender( fileCount ) = 'T';
|
dawn@2
|
369 else
|
dawn@2
|
370 disp('EEEK!');
|
dawn@2
|
371 pause;
|
dawn@2
|
372 end
|
dawn@2
|
373
|
dawn@2
|
374 %how many values are in the string?
|
dawn@2
|
375 spaces = strfind( thestr, ' ' );
|
dawn@2
|
376 numberstr = thestr( spaces(1) : end ); % chop off the file name
|
dawn@2
|
377 frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants
|
dawn@2
|
378
|
dawn@2
|
379 str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values
|
dawn@2
|
380 str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information
|
dawn@2
|
381 str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information
|
dawn@2
|
382 str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information
|
dawn@2
|
383
|
dawn@2
|
384 vars = sscanf( str1, '%f', inf );
|
dawn@2
|
385 % extract the shimmer and jitter values
|
dawn@2
|
386 outputValues = [ outputValues vars( columnIndices )'];
|
dawn@2
|
387
|
dawn@2
|
388 if( getBURGFormants )
|
dawn@2
|
389 spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants'
|
dawn@2
|
390 vars = sscanf( str2( spaces(1) : end ), '%f', inf );
|
dawn@2
|
391 outputValues = stripOutFormantValues( vars, outputValues );
|
dawn@2
|
392 end
|
dawn@2
|
393
|
Dawn@4
|
394 if( getAllFormants )
|
dawn@2
|
395 spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants'
|
dawn@2
|
396 vars = sscanf( str3( spaces(1) : end ), '%f', inf );
|
dawn@2
|
397 outputValues = stripOutFormantValues( vars, outputValues );
|
dawn@2
|
398 end
|
dawn@2
|
399
|
dawn@2
|
400 if( getRobustFormants )
|
dawn@2
|
401 spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants'
|
dawn@2
|
402 vars = sscanf( str4( spaces(1) : end ), '%f', inf );
|
dawn@2
|
403 outputValues = stripOutFormantValues( vars, outputValues );
|
dawn@2
|
404 end
|
dawn@2
|
405
|
dawn@2
|
406 [m n] = size( data );
|
dawn@2
|
407 % sometimes the 'all' formants command gives us fewer formants than
|
dawn@2
|
408 % usual. If this is the case,then we will have to pad with zeros
|
dawn@2
|
409 % for now.
|
dawn@2
|
410 if( n > length( outputValues ) )
|
dawn@2
|
411 lenDiff = n - length( outputValues );
|
dawn@2
|
412 outputValues = [ outputValues zeros( 1, lenDiff ) ];
|
dawn@2
|
413 end
|
dawn@2
|
414
|
dawn@2
|
415 data( fileCount, : ) = outputValues;
|
dawn@2
|
416
|
dawn@2
|
417 end
|
dawn@2
|
418 lineCount = lineCount + 1;
|
dawn@2
|
419
|
dawn@2
|
420 end
|
dawn@2
|
421 fclose(inputFileID);
|
dawn@2
|
422
|
dawn@2
|
423 % ------------ apply the k-means classifier ------------------------
|
dawn@2
|
424
|
dawn@2
|
425 noOfClusters = 2; % we are only trying to identify positive and negative emotions
|
dawn@2
|
426
|
dawn@2
|
427
|
dawn@2
|
428 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
dawn@2
|
429 'start', 'sample', 'Distance', 'cityblock');
|
dawn@2
|
430
|
dawn@2
|
431 %display results grouped by emotion
|
Dawn@4
|
432 fprintf( masterFileOutputID, '\n Emotion grouping \n');
|
Dawn@4
|
433 fprintf( masterFileOutputID, 'cityblock \n');
|
Dawn@4
|
434 [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
435 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID );
|
dawn@2
|
436
|
dawn@2
|
437
|
Dawn@4
|
438 fprintf( masterFileOutputID, 'sqEuclidean \n');
|
dawn@2
|
439 [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
dawn@2
|
440 'start', 'sample', 'Distance', 'sqEuclidean');
|
dawn@2
|
441
|
Dawn@4
|
442 [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
443 [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID );
|
dawn@2
|
444
|
Dawn@4
|
445 % ------------
|
dawn@2
|
446
|
Dawn@4
|
447 % % display results grouped by gender
|
Dawn@4
|
448 % fprintf( masterFileOutputID, '\n Gender grouping \n');
|
Dawn@4
|
449 % noOfClusters = 3;
|
Dawn@4
|
450 %
|
Dawn@4
|
451 % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
452 % 'start', 'sample', 'Distance', 'cityblock');
|
Dawn@4
|
453 %
|
Dawn@4
|
454 % fprintf( masterFileOutputID, 'cityblock \n');
|
Dawn@4
|
455 % [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, gender, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
456 % [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID );
|
Dawn@4
|
457 %
|
Dawn@4
|
458 % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
459 % 'start', 'sample', 'Distance', 'sqEuclidean');
|
Dawn@4
|
460 %
|
Dawn@4
|
461 % fprintf( masterFileOutputID, 'sqEuclidean \n');
|
Dawn@4
|
462 % [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, gender, masterFileOutputID, titleName, DEBUG );
|
Dawn@4
|
463 % [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID );
|
Dawn@4
|
464 %
|
Dawn@4
|
465 %
|
dawn@2
|
466
|
Dawn@4
|
467 %
|
Dawn@4
|
468 % % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
469 % % 'start', 'sample', 'Distance', 'cosine');
|
Dawn@4
|
470 % %
|
Dawn@4
|
471 % % processKMeansResults( 'cosine', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName);
|
Dawn@4
|
472 % %
|
Dawn@4
|
473 % % disp('press space');
|
Dawn@4
|
474 % % pause;
|
Dawn@4
|
475 %
|
Dawn@4
|
476 % % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,...
|
Dawn@4
|
477 % % 'start', 'sample', 'Distance', 'correlation');
|
Dawn@4
|
478 % %
|
Dawn@4
|
479 % % processKMeansResults( 'correlation', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName );
|
dawn@2
|
480
|
dawn@2
|
481 fprintf( masterFileOutputID, '\n' );
|
dawn@2
|
482 fclose( masterFileOutputID );
|
dawn@2
|
483
|
dawn@2
|
484 end
|
dawn@2
|
485
|
dawn@2
|
486 %------------------------------------------------------------------
|
dawn@2
|
487
|
dawn@2
|
488 function [ outputValues ] = stripOutFormantValues( vars, outputValues )
|
dawn@2
|
489
|
dawn@2
|
490 noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only
|
dawn@2
|
491 noOfFormants = vars(1);
|
dawn@2
|
492 % there are 12 measurements for the mean of all formants (so the number
|
dawn@2
|
493 % of formants is not important) for each formant measurement.
|
dawn@2
|
494 if( noOfFormants ~= (noOfFormantValues-12)/24 )
|
dawn@2
|
495 disp('EEK!');
|
dawn@2
|
496 pause;
|
dawn@2
|
497 else
|
dawn@2
|
498 outputValues = [ outputValues vars( 2:end )' ];
|
dawn@2
|
499 end
|
dawn@2
|
500
|
dawn@2
|
501 end
|
dawn@2
|
502
|
dawn@2
|
503 %-------------------------------------------------------------------
|