Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetCPP.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:e1cfa7765647 | 4:92ca03a8fa99 |
---|---|
1 function CPP = func_GetCPP(y, Fs, F0, variables) | |
2 % CPP = func_GetCPP(y, Fs, F0, variables) | |
3 % Input: y, Fs - from wavread | |
4 % F0 - vector of fundamental frequencies | |
5 % variables - global settings | |
6 % Output: CPP vector | |
7 % Notes: Calculates the CPP according to the formula from Hillenbrand, 1994. | |
8 % Currently does not use textgrid information. For very very long files this | |
9 % may be a process-bottleneck. | |
10 % | |
11 % Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA | |
12 % Copyright UCLA SPAPL 2009 | |
13 | |
14 N_periods = variables.Nperiods_EC; | |
15 sampleshift = (Fs / 1000 * variables.frameshift); | |
16 | |
17 CPP = zeros(length(F0), 1) * NaN; | |
18 | |
19 N_ms = round(Fs / 1000); % Quefrency below 1ms are ignored as per Hillenbrand | |
20 | |
21 for k=1:length(F0) | |
22 ks = round(k * sampleshift); | |
23 | |
24 if (ks <= 0 || ks > length(y)) | |
25 continue; | |
26 end | |
27 | |
28 F0_curr = F0(k); | |
29 | |
30 if (isnan(F0_curr)) | |
31 continue; | |
32 end | |
33 | |
34 N0_curr = Fs / F0_curr; | |
35 | |
36 ystart = round(ks - N_periods/2*N0_curr); | |
37 yend = round(ks + N_periods/2*N0_curr) - 1; | |
38 | |
39 if (ystart <= 0) | |
40 continue; | |
41 end; | |
42 | |
43 if (yend > length(y)) | |
44 continue; | |
45 end; | |
46 | |
47 yseg = y(ystart:yend); | |
48 yseg = yseg .* hamming(length(yseg)); %windowing | |
49 YSEG = fft(yseg); | |
50 yseg_c = ifft(log(abs(YSEG))); | |
51 yseg_c_db = 10*log10(yseg_c .^ 2); | |
52 | |
53 yseg_c_db = yseg_c_db(1:floor(length(yseg)/2)); | |
54 [vals, inx] = func_pickpeaks(yseg_c_db(N_ms:end)', 2*N0_curr); | |
55 [pos, pinx] = min(abs(inx - N0_curr)); | |
56 | |
57 if (~isempty(pinx)) | |
58 inx = inx(pinx(1)); | |
59 vals = yseg_c_db(inx+N_ms-1); | |
60 p = polyfit([N_ms:length(yseg_c_db)], yseg_c_db(N_ms:end)', 1); | |
61 base_val = p(1) * (inx+N_ms-1) + p(2); | |
62 CPP(k) = vals - base_val; | |
63 | |
64 % figure; | |
65 % plot(yseg_c_db); hold on; | |
66 % plot(inx+N_ms-1, vals, 'rx'); | |
67 % plot([N_ms:length(yseg_c_db)], polyval(p,[N_ms:length(yseg_c_db)]), 'g'); | |
68 | |
69 end | |
70 | |
71 end | |
72 |