Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_GetEnergy.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 E = func_GetEnergy(y, F0, Fs, variables) | |
2 % E = func_GetEnergy(y, F0, Fs, variables) | |
3 % Input: y, Fs - from wavread | |
4 % F0 - vector of fundamental frequencies | |
5 % variables - global settings | |
6 % Output: Energy vector | |
7 % Notes: Calculates the energy, normalized for F0. This is done by using a | |
8 % variable length window consisting of 5 pitch periods, according to the F0 | |
9 % at a particular point in time. | |
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 E = zeros(length(F0), 1) * NaN; | |
18 | |
19 for k=1:length(F0) | |
20 ks = round(k * sampleshift); | |
21 | |
22 if (ks <= 0 || ks > length(y)) | |
23 continue; | |
24 end | |
25 | |
26 F0_curr = F0(k); | |
27 | |
28 if (isnan(F0_curr)) | |
29 continue; | |
30 end | |
31 | |
32 N0_curr = Fs/F0_curr; | |
33 | |
34 ystart = round(ks - N_periods/2 * N0_curr); | |
35 yend = round(ks + N_periods/2 * N0_curr) - 1; | |
36 | |
37 if (ystart <= 0) | |
38 continue; | |
39 end | |
40 | |
41 if (yend > length(y)) | |
42 continue; | |
43 end | |
44 | |
45 yseg = y(ystart:yend); | |
46 | |
47 E(k) = sum(yseg .^ 2); | |
48 | |
49 end | |
50 |