Dawn@4
|
1 function [] = SVM_Formants_Singing( varargin )
|
Dawn@4
|
2
|
Dawn@4
|
3 cd 'C:\Users\dawn\Dropbox\TestResults'
|
Dawn@4
|
4
|
Dawn@4
|
5 DEBUG = 0;
|
Dawn@4
|
6 % output results file name
|
Dawn@4
|
7 masterFileOutputID = fopen( 'SVM_paper_SingingFormantsStats.txt', 'a' );
|
Dawn@4
|
8 % input results file name
|
Dawn@4
|
9 inputFileName = 'paper_singingFormantsStats.txt';
|
Dawn@4
|
10
|
Dawn@4
|
11 % This function allows the user to stipulate which Singing voice LLD's they
|
Dawn@4
|
12 % wish to forward to a k-means classifier and produces a file of
|
Dawn@4
|
13 % performance characteristics. Input arguments stipulate the LLD's and
|
Dawn@4
|
14 % there is a choice of:-
|
Dawn@4
|
15 %
|
Dawn@4
|
16 % ---- PRAAT FORMANT MEASUREMENTS ----
|
Dawn@4
|
17 % '_Formant_Burg'
|
Dawn@4
|
18 % '_Formant_all'
|
Dawn@4
|
19 % '_Formant_robust'
|
Dawn@4
|
20 %
|
Dawn@4
|
21 % A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt
|
Dawn@4
|
22 % is produced that contains the results of the k-mean classification for
|
Dawn@4
|
23 % the LLD's specified and named in the result document title.
|
Dawn@4
|
24
|
Dawn@4
|
25 fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName);
|
Dawn@4
|
26 inputFileID = fopen( inputFileName );
|
Dawn@4
|
27
|
Dawn@4
|
28 % get the column numbers of the results that we want to classify
|
Dawn@4
|
29
|
Dawn@4
|
30 % COLUMN NUMBER : METRIC
|
Dawn@4
|
31 %
|
Dawn@4
|
32 % ------------- BURG FORMANTS ---------------
|
Dawn@4
|
33 % 11 : Number of BURG formants listed = nBF
|
Dawn@4
|
34 %
|
Dawn@4
|
35 % THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT
|
Dawn@4
|
36 nMetrics = 24;
|
Dawn@4
|
37 %
|
Dawn@4
|
38 % 12 : mean frequency of the first BURG formant
|
Dawn@4
|
39 % 13 : variance of the first BURG formant
|
Dawn@4
|
40 % 14 : minimum frequency of the first BURG formant
|
Dawn@4
|
41 % 15 : maximum frequency of the first BURG formant
|
Dawn@4
|
42 % 16 : mean Frequency Derivative of the first BURG formant
|
Dawn@4
|
43 % 17 : varience of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
44 % 18 : min of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
45 % 19 : max of the Frequency Derivative of the first BURG formant
|
Dawn@4
|
46 % 20 : mean of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
47 % 21 : varience of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
48 % 22 : min of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
49 % 23 : max of the Frequency 2nd Derivative of the first BURG formant
|
Dawn@4
|
50 % 24 : mean of the Bandwidth of the first BURG formant
|
Dawn@4
|
51 % 25 : varience of the Bandwidth of the first BURG formant
|
Dawn@4
|
52 % 26 : min of the Bandwidth of the first BURG formant
|
Dawn@4
|
53 % 27 : max of the Bandwidth of the first BURG formant
|
Dawn@4
|
54 % 28 : mean of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
55 % 29 : varience of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
56 % 30 : min of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
57 % 31 : max of the Bandwidth Derivative of the first BURG formant
|
Dawn@4
|
58 % 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
59 % 33 : var of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
60 % 34 : min of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
61 % 35 : max of the Bandwidth 2nd Derivative of the first BURG formant
|
Dawn@4
|
62 %
|
Dawn@4
|
63 % ....... there are nMetrics for each formant in nBF formants, so cycle
|
Dawn@4
|
64 % through until the last is reached ......
|
Dawn@4
|
65 %
|
Dawn@4
|
66 % 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant
|
Dawn@4
|
67 % 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant
|
Dawn@4
|
68 % 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant
|
Dawn@4
|
69 % 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant
|
Dawn@4
|
70 % 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
71 % 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
72 % 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
73 % 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant
|
Dawn@4
|
74 % 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
75 % 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
76 % 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
77 % 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
78 % 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
79 % 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
80 % 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
81 % 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant
|
Dawn@4
|
82 % 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
83 % 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
84 % 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
85 % 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant
|
Dawn@4
|
86 % 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
87 % 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
88 % 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
89 % 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant
|
Dawn@4
|
90 %
|
Dawn@4
|
91 % FOR THE MEAN OF ALL BURG FORMANTS
|
Dawn@4
|
92 % 36 + (nBF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
93 % 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
94 % 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
95 % 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
96 % 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
97 % 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
98 % 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
99 % 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
100 % 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
101 % 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
102 % 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
103 % 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
104 %
|
Dawn@4
|
105 % ------------- ALL FORMANTS ---------------
|
Dawn@4
|
106 %
|
Dawn@4
|
107 % 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF
|
Dawn@4
|
108 %
|
Dawn@4
|
109 % startOfALLMeasurements = 36 + (nBF*nMetrics) + 13;
|
Dawn@4
|
110 %
|
Dawn@4
|
111 % startOfALLMeasurements : mean frequency of the first ALL formant
|
Dawn@4
|
112 % startOfALLMeasurements + 1 : variance of the first ALL formant
|
Dawn@4
|
113 % startOfALLMeasurements + 2 : minimum frequency of the first ALL formant
|
Dawn@4
|
114 % startOfALLMeasurements + 3 : maximum frequency of the first ALL formant
|
Dawn@4
|
115 % startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant
|
Dawn@4
|
116 % startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
117 % startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
118 % startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant
|
Dawn@4
|
119 % startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
120 % startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
121 % startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
122 % startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant
|
Dawn@4
|
123 % startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant
|
Dawn@4
|
124 % startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant
|
Dawn@4
|
125 % startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant
|
Dawn@4
|
126 % startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant
|
Dawn@4
|
127 % startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
128 % startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
129 % startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
130 % startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant
|
Dawn@4
|
131 % startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
132 % startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
133 % startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
134 % startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant
|
Dawn@4
|
135 %
|
Dawn@4
|
136 % ....... there are nMetrics for each formant in nAF formants, so cycle
|
Dawn@4
|
137 % through until the last is reached ......
|
Dawn@4
|
138 %
|
Dawn@4
|
139 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant
|
Dawn@4
|
140 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant
|
Dawn@4
|
141 % startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant
|
Dawn@4
|
142 % startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant
|
Dawn@4
|
143 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
144 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
145 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
146 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant
|
Dawn@4
|
147 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
148 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
149 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
150 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
151 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
152 % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
153 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
154 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant
|
Dawn@4
|
155 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
156 % startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
157 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
158 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant
|
Dawn@4
|
159 % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
160 % startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
161 % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
162 % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant
|
Dawn@4
|
163 %
|
Dawn@4
|
164 % FOR THE MEAN OF ALL ALL FORMANTS
|
Dawn@4
|
165 % startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
166 % startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
167 % startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
168 % startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
169 % startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
170 % startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
171 % startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
172 % startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
173 % startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
174 % startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
175 % startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
176 % startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
177 %
|
Dawn@4
|
178 % ------------- ROBUST FORMANTS ---------------
|
Dawn@4
|
179 %
|
Dawn@4
|
180 % startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF
|
Dawn@4
|
181 %
|
Dawn@4
|
182 % startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13;
|
Dawn@4
|
183 %
|
Dawn@4
|
184 % startOfROBUSTMeasurements : mean frequency of the first ROBUST formant
|
Dawn@4
|
185 % startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant
|
Dawn@4
|
186 % startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant
|
Dawn@4
|
187 % startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant
|
Dawn@4
|
188 % startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
189 % startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
190 % startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
191 % startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant
|
Dawn@4
|
192 % startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
193 % startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
194 % startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
195 % startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
196 % startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
197 % startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
198 % startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
199 % startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant
|
Dawn@4
|
200 % startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
201 % startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
202 % startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
203 % startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant
|
Dawn@4
|
204 % startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
205 % startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
206 % startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
207 % startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant
|
Dawn@4
|
208 %
|
Dawn@4
|
209 % ....... there are nMetrics for each formant in nRF formants, so cycle
|
Dawn@4
|
210 % through until the last is reached ......
|
Dawn@4
|
211 %
|
Dawn@4
|
212 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant
|
Dawn@4
|
213 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant
|
Dawn@4
|
214 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant
|
Dawn@4
|
215 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant
|
Dawn@4
|
216 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
217 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
218 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
219 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant
|
Dawn@4
|
220 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
221 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
222 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
223 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
224 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
225 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
226 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
227 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant
|
Dawn@4
|
228 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
229 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
230 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
231 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant
|
Dawn@4
|
232 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
233 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
234 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
235 % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant
|
Dawn@4
|
236 %
|
Dawn@4
|
237 % FOR THE MEAN OF ALL ROBUST FORMANTS
|
Dawn@4
|
238 % startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency
|
Dawn@4
|
239 % startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency
|
Dawn@4
|
240 % startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency
|
Dawn@4
|
241 % startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency
|
Dawn@4
|
242 % startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative
|
Dawn@4
|
243 % startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative
|
Dawn@4
|
244 % startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative
|
Dawn@4
|
245 % startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative
|
Dawn@4
|
246 % startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
247 % startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
248 % startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
249 % startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative
|
Dawn@4
|
250 %
|
Dawn@4
|
251
|
Dawn@4
|
252 noOfArguments = length(varargin);
|
Dawn@4
|
253 columnIndices = [];
|
Dawn@4
|
254
|
Dawn@4
|
255 getBURGFormants = 0;
|
Dawn@4
|
256 getAllFormants=0;
|
Dawn@4
|
257 getRobustFormants=0;
|
Dawn@4
|
258
|
Dawn@4
|
259 for i=1 : noOfArguments
|
Dawn@4
|
260 if( strcmp( varargin{i}, 'formant_Burg' ))
|
Dawn@4
|
261 getBURGFormants = 1;
|
Dawn@4
|
262 elseif( strcmp( varargin{i}, 'formant_all' ))
|
Dawn@4
|
263 getAllFormants=1;
|
Dawn@4
|
264 elseif( strcmp( varargin{i}, 'formant_robust' ))
|
Dawn@4
|
265 getRobustFormants=1;
|
Dawn@4
|
266 end
|
Dawn@4
|
267 end
|
Dawn@4
|
268
|
Dawn@4
|
269 titleName = '';
|
Dawn@4
|
270 for i=1 : noOfArguments
|
Dawn@4
|
271 titleName = [ titleName varargin{i} '_'];
|
Dawn@4
|
272 fprintf( masterFileOutputID, '%s_', varargin{i} );
|
Dawn@4
|
273 end
|
Dawn@4
|
274
|
Dawn@4
|
275 fprintf( masterFileOutputID, '\t' );
|
Dawn@4
|
276
|
Dawn@4
|
277 % -------------------- get the data from the results file ---------------
|
Dawn@4
|
278 lineCount = 0;
|
Dawn@4
|
279 fileCount = 0;
|
Dawn@4
|
280 data = [];
|
Dawn@4
|
281 groups = [];
|
Dawn@4
|
282
|
Dawn@4
|
283 while( ~(feof(inputFileID)) )
|
Dawn@4
|
284
|
Dawn@4
|
285 outputValues = [];
|
Dawn@4
|
286
|
Dawn@4
|
287 thestr = fgetl(inputFileID);
|
Dawn@4
|
288 if( lineCount > 10 ) % skip the file header
|
Dawn@4
|
289 fileCount = fileCount + 1;
|
Dawn@4
|
290
|
Dawn@4
|
291 % determine whether we have a positive or negative sample
|
Dawn@4
|
292 sampleEmotion( fileCount ) = 'U';
|
Dawn@4
|
293 if( ~(isempty(strfind(thestr,'pos'))))
|
Dawn@4
|
294 % sample is positive
|
Dawn@4
|
295 sampleEmotion( fileCount ) = 'P';
|
Dawn@4
|
296 groups( fileCount ) = 1;
|
Dawn@4
|
297 elseif( ~(isempty(strfind(thestr,'neg'))))
|
Dawn@4
|
298 % sample is negative
|
Dawn@4
|
299 sampleEmotion( fileCount ) = 'N';
|
Dawn@4
|
300 groups( fileCount ) = 0;
|
Dawn@4
|
301 else
|
Dawn@4
|
302 disp('EEEK!');
|
Dawn@4
|
303 pause;
|
Dawn@4
|
304 end
|
Dawn@4
|
305
|
Dawn@4
|
306 % % determine whether we have a male, female or trans sample
|
Dawn@4
|
307 % gender( fileCount ) = '?';
|
Dawn@4
|
308 % if( ~(isempty(strfind(thestr,'fem'))))
|
Dawn@4
|
309 % % gender is female
|
Dawn@4
|
310 % gender( fileCount ) = 'F';
|
Dawn@4
|
311 % elseif( ~(isempty(strfind(thestr,'male'))))
|
Dawn@4
|
312 % % gender is male
|
Dawn@4
|
313 % gender( fileCount ) = 'M';
|
Dawn@4
|
314 % elseif( ~(isempty(strfind(thestr,'trans'))))
|
Dawn@4
|
315 % % gender is trans
|
Dawn@4
|
316 % gender( fileCount ) = 'T';
|
Dawn@4
|
317 % else
|
Dawn@4
|
318 % disp('EEEK!');
|
Dawn@4
|
319 % pause;
|
Dawn@4
|
320 % end
|
Dawn@4
|
321
|
Dawn@4
|
322 %how many values are in the string?
|
Dawn@4
|
323 spaces = strfind( thestr, ' ' );
|
Dawn@4
|
324 numberstr = thestr( spaces(1) : end ); % chop off the file name
|
Dawn@4
|
325 frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants
|
Dawn@4
|
326
|
Dawn@4
|
327 % str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values
|
Dawn@4
|
328 str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information
|
Dawn@4
|
329 str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information
|
Dawn@4
|
330 str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information
|
Dawn@4
|
331
|
Dawn@4
|
332
|
Dawn@4
|
333 % vars = sscanf( str1, '%f', inf );
|
Dawn@4
|
334 % % extract the shimmer and jitter values
|
Dawn@4
|
335 % outputValues = [ outputValues vars( columnIndices )'];
|
Dawn@4
|
336
|
Dawn@4
|
337 if( getBURGFormants )
|
Dawn@4
|
338 spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
339 vars = sscanf( str2( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
340 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
341 end
|
Dawn@4
|
342
|
Dawn@4
|
343 if( getAllFormants )
|
Dawn@4
|
344 spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
345 vars = sscanf( str3( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
346 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
347 end
|
Dawn@4
|
348
|
Dawn@4
|
349 if( getRobustFormants )
|
Dawn@4
|
350 spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants'
|
Dawn@4
|
351 vars = sscanf( str4( spaces(1) : end ), '%f', inf );
|
Dawn@4
|
352 outputValues = stripOutFormantValues( vars, outputValues );
|
Dawn@4
|
353 end
|
Dawn@4
|
354
|
Dawn@4
|
355 [m n] = size( data );
|
Dawn@4
|
356 % sometimes the 'all' formants command gives us fewer formants than
|
Dawn@4
|
357 % usual. If this is the case,then we will have to pad with zeros
|
Dawn@4
|
358 % for now.
|
Dawn@4
|
359 if( n > length( outputValues ) )
|
Dawn@4
|
360 lenDiff = n - length( outputValues );
|
Dawn@4
|
361 outputValues = [ outputValues zeros( 1, lenDiff ) ];
|
Dawn@4
|
362 elseif( n < length( outputValues ) )
|
Dawn@4
|
363 lenDiff = length( outputValues ) - n;
|
Dawn@4
|
364 outputValues = [ outputValues zeros( 1, lenDiff ) ];
|
Dawn@4
|
365 end
|
Dawn@4
|
366
|
Dawn@4
|
367 data( fileCount, : ) = outputValues;
|
Dawn@4
|
368
|
Dawn@4
|
369 end
|
Dawn@4
|
370 lineCount = lineCount + 1;
|
Dawn@4
|
371
|
Dawn@4
|
372 end
|
Dawn@4
|
373 fclose(inputFileID);
|
Dawn@4
|
374
|
Dawn@4
|
375
|
Dawn@4
|
376
|
Dawn@4
|
377 % ------------ apply the SVM classifier ------------------------
|
Dawn@4
|
378
|
Dawn@4
|
379 resultMatrix = [];
|
Dawn@4
|
380
|
Dawn@4
|
381 noOfIterations = 10;
|
Dawn@4
|
382
|
Dawn@4
|
383 for n = 1:noOfIterations
|
Dawn@4
|
384 % Randomly select training and test sets, perhaps we should try all and
|
Dawn@4
|
385 % choose the best?
|
Dawn@4
|
386 [train, test] = crossvalind('holdOut',groups);
|
Dawn@4
|
387 cp = classperf(groups);
|
Dawn@4
|
388
|
Dawn@4
|
389 % Use a linear support vector machine classifier
|
Dawn@4
|
390 svmStruct = svmtrain(data(train,:),groups(train));
|
Dawn@4
|
391 classes = svmclassify(svmStruct,data(test,:));
|
Dawn@4
|
392 % See how well the classifier performed
|
Dawn@4
|
393 classperf(cp,classes,test);
|
Dawn@4
|
394 numbers = cp.CountingMatrix;
|
Dawn@4
|
395
|
Dawn@4
|
396 resultMatrix (n,:,:) = cp.DiagnosticTable;
|
Dawn@4
|
397 %
|
Dawn@4
|
398 end
|
Dawn@4
|
399
|
Dawn@4
|
400
|
Dawn@4
|
401
|
Dawn@4
|
402
|
Dawn@4
|
403 % for emotion detection give the confusion matrix as
|
Dawn@4
|
404 % -----------------------------------------------------------------
|
Dawn@4
|
405 % positive correctly identified | positive incorrectly identified (1,2)
|
Dawn@4
|
406 % negative incorrectly identified (2,1) | negative correctly identified
|
Dawn@4
|
407 % ------------------------------------------------------------------
|
Dawn@4
|
408
|
Dawn@4
|
409 % takes the average of 10 iterations - do we want to take the best?
|
Dawn@4
|
410
|
Dawn@4
|
411 meanResults(1,1) = mean( resultMatrix(:,1,1) );
|
Dawn@4
|
412 meanResults(1,2) = mean( resultMatrix(:,2,1) );
|
Dawn@4
|
413 meanResults(2,1) = mean( resultMatrix(:,1,2) );
|
Dawn@4
|
414 meanResults(2,2) = mean( resultMatrix(:,2,2) );
|
Dawn@4
|
415
|
Dawn@4
|
416 meanResults(3,:)=0;
|
Dawn@4
|
417 meanResults(:,3)=0;
|
Dawn@4
|
418
|
Dawn@4
|
419 meanResults(3,3) = (meanResults(1,1) + meanResults(2,2));% / sum(sum(meanResults));
|
Dawn@4
|
420
|
Dawn@4
|
421 % convert to percentages
|
Dawn@4
|
422 % how many of each sample do we have?
|
Dawn@4
|
423 groupNumbers = unique( groups( test ));
|
Dawn@4
|
424 groupNames = unique( sampleEmotion( test ));
|
Dawn@4
|
425 sampleEmotionTest = sampleEmotion( test );
|
Dawn@4
|
426 % which group is which emotion?
|
Dawn@4
|
427 thisGroupNumber = groupNumbers(1);
|
Dawn@4
|
428 thisGroup = find( groups( test ) == thisGroupNumber );
|
Dawn@4
|
429 thisGroupName = unique( sampleEmotionTest( thisGroup ));
|
Dawn@4
|
430
|
Dawn@4
|
431 thatGroupNumber = groupNumbers(2);
|
Dawn@4
|
432 thatGroup = find( groups( test ) == thatGroupNumber );
|
Dawn@4
|
433 thatGroupName = unique( sampleEmotionTest( thatGroup ));
|
Dawn@4
|
434
|
Dawn@4
|
435 if(length( thisGroupName ) ~= 1 )
|
Dawn@4
|
436 disp('ARGH!');
|
Dawn@4
|
437 pause;
|
Dawn@4
|
438 end
|
Dawn@4
|
439
|
Dawn@4
|
440 thisGroupNumberOfSamples = length( thisGroup );
|
Dawn@4
|
441 thatGroupNumberOfSamples = length( thatGroup );
|
Dawn@4
|
442
|
Dawn@4
|
443 if( thisGroupName == 'P' )
|
Dawn@4
|
444 %swap all the variables ready for checking
|
Dawn@4
|
445 temp = thisGroupNumberOfSamples;
|
Dawn@4
|
446 thisGroupNumberOfSamples = thatGroupNumberOfSamples;
|
Dawn@4
|
447 thatGroupNumberOfSamples = temp;
|
Dawn@4
|
448
|
Dawn@4
|
449 temp = thisGroupName;
|
Dawn@4
|
450 thisGroupName = thatGroupName
|
Dawn@4
|
451 thatGroupName = temp;
|
Dawn@4
|
452 disp('CHECK ME!');
|
Dawn@4
|
453 end
|
Dawn@4
|
454
|
Dawn@4
|
455 if( thisGroupName == 'N' )
|
Dawn@4
|
456 % group 0 is negative
|
Dawn@4
|
457 if( sum( meanResults(1,:) ) == thisGroupNumberOfSamples )
|
Dawn@4
|
458 %if the elements in the first row add up to the number of negative
|
Dawn@4
|
459 %samples, then swap the rows because we want the top row to be the
|
Dawn@4
|
460 %results for the positive samples
|
Dawn@4
|
461 temp(:,1) = meanResults(1:2,2);
|
Dawn@4
|
462 temp(:,2) = meanResults(1:2,1);
|
Dawn@4
|
463 temp2(1,:) = temp(2,:);
|
Dawn@4
|
464 temp2(2,:) = temp(1,:);
|
Dawn@4
|
465
|
Dawn@4
|
466 meanResults(1:2,1) = temp2(:,1);
|
Dawn@4
|
467 meanResults(1:2,2) = temp2(:,2);
|
Dawn@4
|
468
|
Dawn@4
|
469 % check the number of positive samples
|
Dawn@4
|
470 if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ...
|
Dawn@4
|
471 && ( thatGroupName == 'P' ) )
|
Dawn@4
|
472 % row 1 is positive
|
Dawn@4
|
473 disp('matrix correct');
|
Dawn@4
|
474 else
|
Dawn@4
|
475 disp('ARGH!');
|
Dawn@4
|
476 pause;
|
Dawn@4
|
477 end
|
Dawn@4
|
478
|
Dawn@4
|
479 elseif( sum( meanResults(2,:) ) == thisGroupNumberOfSamples )
|
Dawn@4
|
480
|
Dawn@4
|
481 % the elements in the second row add up to the number of negative
|
Dawn@4
|
482 % samples, so the matrix is the correct way around
|
Dawn@4
|
483
|
Dawn@4
|
484 % check the number of positive samples
|
Dawn@4
|
485 if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ...
|
Dawn@4
|
486 && ( thatGroupName == 'P' ) )
|
Dawn@4
|
487 % row 0 is positive
|
Dawn@4
|
488 disp('matrix correct');
|
Dawn@4
|
489 else
|
Dawn@4
|
490 disp('ARGH!');
|
Dawn@4
|
491 pause;
|
Dawn@4
|
492 end
|
Dawn@4
|
493 end
|
Dawn@4
|
494 end
|
Dawn@4
|
495
|
Dawn@4
|
496 % calculate the percentages
|
Dawn@4
|
497 numberOfSamples = sum(sum( meanResults(1:2,1:2)));
|
Dawn@4
|
498 percentageResults = meanResults;
|
Dawn@4
|
499 percentageResults(1,1) = meanResults(1,1) / numberOfSamples;
|
Dawn@4
|
500 percentageResults(1,2) = meanResults(1,2) / numberOfSamples;
|
Dawn@4
|
501 percentageResults(2,1) = meanResults(2,1) / numberOfSamples;
|
Dawn@4
|
502 percentageResults(2,2) = meanResults(2,2) / numberOfSamples;
|
Dawn@4
|
503 percentageResults(3,3) = meanResults(3,3) / numberOfSamples;
|
Dawn@4
|
504
|
Dawn@4
|
505 percentageResults = percentageResults * 100
|
Dawn@4
|
506
|
Dawn@4
|
507 confusionMatrix = percentageResults;
|
Dawn@4
|
508 fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3));
|
Dawn@4
|
509
|
Dawn@4
|
510 % print latex results to the screen
|
Dawn@4
|
511 str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(1,1), percentageResults(1,2) );
|
Dawn@4
|
512 disp(str1);
|
Dawn@4
|
513 str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(2,1), percentageResults(2,2) );
|
Dawn@4
|
514 disp(str1);
|
Dawn@4
|
515 str1 = sprintf(' & & & %2.2f \\\\',percentageResults(3,3) );
|
Dawn@4
|
516 disp(str1);
|
Dawn@4
|
517
|
Dawn@4
|
518 fprintf( masterFileOutputID, '\n' );
|
Dawn@4
|
519 fclose( masterFileOutputID );
|
Dawn@4
|
520
|
Dawn@4
|
521 end
|
Dawn@4
|
522
|
Dawn@4
|
523 %------------------------------------------------------------------
|
Dawn@4
|
524
|
Dawn@4
|
525 function [ outputValues ] = stripOutFormantValues( vars, outputValues )
|
Dawn@4
|
526
|
Dawn@4
|
527 noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only
|
Dawn@4
|
528 noOfFormants = vars(1);
|
Dawn@4
|
529 % there are 12 measurements for the mean of all formants (so the number
|
Dawn@4
|
530 % of formants is not important) for each formant measurement.
|
Dawn@4
|
531 if( noOfFormants ~= (noOfFormantValues-12)/24 )
|
Dawn@4
|
532 disp('EEK!');
|
Dawn@4
|
533 pause;
|
Dawn@4
|
534 else
|
Dawn@4
|
535 outputValues = [ outputValues vars( 2:end )' ];
|
Dawn@4
|
536 end
|
Dawn@4
|
537
|
Dawn@4
|
538 end
|
Dawn@4
|
539
|
Dawn@4
|
540 %-------------------------------------------------------------------
|