Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_StraightPitch.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 [F0, V] = func_StraightPitch(y, Fs, variables, textgridfile) | |
2 % [F0, V] = func_StraightPitch(y, Fs, variables, textgridfile) | |
3 % Input: y, Fs - from wavread | |
4 % variables - settings | |
5 % textgridfile - this is optional | |
6 % Output: F0, V - F0 and voicing vectors | |
7 % Notes: This function calls the Straight functions. Using textgrid | |
8 % segmentation helps to speed up the processing. | |
9 % | |
10 % Author: Yen-Liang Shue, Speech Processing and Auditory Perception Laboratory, UCLA | |
11 % Copyright UCLA SPAPL 2009 | |
12 | |
13 maxF0 = variables.maxstrF0; | |
14 minF0 = variables.minstrF0; | |
15 maxdur = variables.maxstrdur; | |
16 | |
17 prmF0in.DisplayPlots = 0; | |
18 prmF0in.ThresholdForVUV = 0.1; | |
19 prmF0in.ThresholdForSilence = 1; | |
20 prmF0in.F0searchLowerBound = minF0; | |
21 prmF0in.F0searchUpperBound = maxF0; | |
22 %prmF0in.VUVthresholdofAC1 = 0.9000; | |
23 | |
24 warning off | |
25 | |
26 % break up the file if it is too big (i.e. > 15sec) | |
27 if (nargin == 3) % do the whole file, no textgrid data available | |
28 L = floor(length(y)/Fs * 1000) - 1; | |
29 F0 = zeros(L, 1); | |
30 | |
31 if (length(y) / Fs > maxdur) | |
32 % find suitable places to chop | |
33 cnt = 1; | |
34 startx = 1; | |
35 endx = startx + floor(maxdur*Fs); | |
36 isgood = 1; | |
37 | |
38 while(startx < length(y)) | |
39 if (startx == 1) | |
40 yseg = y(startx : endx); % extra millisecond | |
41 else | |
42 yseg = y(startx - floor(F0 / 1000) - 10 : endx); % extra millisecond | |
43 end | |
44 %fprintf('Processing segment %d to %d\n', startx, endx); | |
45 | |
46 try | |
47 [F0seg, V, auxouts, prmF0out] = MulticueF0v14(yseg,Fs,prmF0in); | |
48 catch | |
49 isgood = 0; | |
50 break; | |
51 end | |
52 | |
53 F0(cnt:cnt+length(F0seg)-1) = F0seg; | |
54 cnt = cnt + length(F0seg); | |
55 startx = endx + 1; | |
56 | |
57 remainder = length(y) - endx - 1; | |
58 if (remainder > maxdur*Fs) | |
59 endx = startx + floor(maxdur*Fs); | |
60 else | |
61 endx = length(y); | |
62 end | |
63 end | |
64 | |
65 if (~isgood) % multicue failed | |
66 fprintf('Multicue failed: switching to exstraightsource\n'); | |
67 F0 = exstraightsource(y,Fs,prmF0in); | |
68 F0 = F0(1:L)'; | |
69 V = ones(size(F0seg)); | |
70 end | |
71 | |
72 else | |
73 try | |
74 [F0, V, auxouts, prmF0out] = MulticueF0v14(y,Fs,prmF0in); | |
75 catch | |
76 fprintf('Multicue failed: switching to exstraightsource\n'); | |
77 F0 = exstraightsource(y,Fs, prmF0in); | |
78 F0 = F0(1:L)'; | |
79 V = ones(size(F0)); | |
80 end | |
81 end | |
82 else % use textgrid data | |
83 % get the labels to ignore from the settings | |
84 tbuffer = variables.tbuffer; | |
85 ignorelabels = textscan(variables.TextgridIgnoreList, '%s', 'delimiter', ','); | |
86 ignorelabels = ignorelabels{1}; | |
87 | |
88 [labels, start, stop] = func_readTextgrid(textgridfile); | |
89 | |
90 labels_tmp = []; | |
91 start_tmp = []; | |
92 stop_tmp = []; | |
93 | |
94 for k=1:length(variables.TextgridTierNumber) | |
95 inx = variables.TextgridTierNumber(k); | |
96 if (inx <= length(labels)) | |
97 labels_tmp = [labels_tmp; labels{inx}]; | |
98 start_tmp = [start_tmp; start{inx}]; | |
99 stop_tmp = [stop_tmp; stop{inx}]; | |
100 end | |
101 end | |
102 | |
103 labels = labels_tmp; | |
104 start = start_tmp * 1000; % milliseconds | |
105 stop = stop_tmp * 1000; % milliseconds | |
106 | |
107 L = floor(length(y) / Fs * 1000) - 1; | |
108 | |
109 F0 = zeros(L, 1) * NaN; | |
110 V = zeros(L, 1) * NaN; | |
111 | |
112 for k=1:length(start) | |
113 | |
114 switch(labels{k}) | |
115 case ignorelabels | |
116 continue; % skip anything that is within the ignore list | |
117 end | |
118 | |
119 tstart = start(k) - tbuffer; | |
120 tstop = stop(k) + tbuffer; | |
121 | |
122 sstart = floor(tstart / 1000 * Fs); | |
123 sstop = ceil(tstop / 1000 * Fs); | |
124 | |
125 sstart(sstart <= 0) = 1; | |
126 sstop(sstop > length(y)) = length(y); | |
127 | |
128 yseg = y(sstart:sstop); | |
129 | |
130 try | |
131 [F0seg, Vseg, auxouts, prmF0out] = MulticueF0v14(yseg,Fs,prmF0in); | |
132 catch | |
133 fprintf('Multicue failed: switching to exstraightsource\n'); | |
134 F0seg = exstraightsource(yseg,Fs,prmF0in); | |
135 F0seg = F0seg(2:end-1)'; | |
136 Vseg = ones(size(F0seg)); | |
137 end | |
138 | |
139 tstart = floor(tstart); | |
140 tstart(tstart <= 0) = 1; | |
141 F0(tstart:tstart+length(F0seg)-1) = F0seg; | |
142 V(tstart:tstart+length(Vseg)-1) = Vseg; | |
143 | |
144 if (length(F0) > L) | |
145 F0 = F0(1:L); | |
146 end | |
147 | |
148 end | |
149 | |
150 end | |
151 | |
152 % sometimes Straight outputs 0s for F0 | |
153 F0(F0 == 0) = NaN; |