41 #include "EST_speech_class.h"
42 #include "EST_string_aux.h"
43 #include "EST_cmd_line.h"
44 #include "EST_cmd_line_options.h"
45 #include "sigpr/EST_sigpr_utt.h"
46 #include "sigpr/EST_filter.h"
48 #define EPSILON (0.0001)
50 #define DEFAULT_FRAME_SIZE 0.01
51 #define DEFAULT_FRAME_FACTOR 2.0
52 #define DEFAULT_LPC_ORDER 16
53 #define DEFAULT_REF_ORDER 16
54 #define DEFAULT_CEP_ORDER 12
55 #define DEFAULT_FBANK_ORDER 20
56 #define DEFAULT_MELCEP_ORDER 12
57 #define DEFAULT_WINDOW "hamming"
58 #define DEFAULT_PREEMPH 0
59 #define DEFAULT_LIFTER 0
64 #define MINIMUM_PITCH_PERIOD (0.0033) // 300 hz
65 #define MAXIMUM_PITCH_PERIOD (0.02) // 50 Hz
66 #define DEFAULT_PITCH_PERIOD (0.01) // 100 Hz
80 " lpc linear predictive coding\n"
81 " cep cepstrum coding from lpc coefficients\n"
82 " melcep Mel scale cepstrum coding via fbank\n"
83 " fbank Mel scale log filterbank analysis\n"
84 " lsf line spectral frequencies\n"
85 " ref Linear prediction reflection coefficients\n"
88 " energy: root mean square energy\n";
142 int main(
int argc,
char *argv[])
150 EST_StrList coef_list, delta_list, acc_list, tlist, map;
155 EST_String(
"[input file] -o [output file]\n")+
156 "Summary: generate acoustic feature vectors for a waveform file \n"
157 "use \"-\" to make input and output files stdin/out \n"
158 "-h Options help \n\n" +
159 options_wave_input() +
160 options_track_output() +
" \n"
161 "-shift <float> frame spacing in seconds for fixed frame analysis. This \n"
162 " doesn't have to be the same as the output file spacing - the \n"
163 " S option can be used to resample the track before saving \n"
164 " default: "+ftoString(DEFAULT_FRAME_SIZE) +
"\n\n"
165 "-factor <float> Frames lengths will be FACTOR times the \n"
166 " local pitch period. \n"
167 " default: "+ftoString(DEFAULT_FRAME_FACTOR) +
"\n\n"
168 "-pm <ifile> Pitch mark file name. This is used to \n"
169 " specify the positions of the analysis frames for pitch \n"
170 " synchronous analysis. Pitchmark files are just standard \n"
171 " track files, but the channel information is ignored and \n"
172 " only the time positions are used\n"
173 "-size <float> If specified with pm, size is used as the \n"
174 " fixed window size (times factor) rather than size within \n"
177 "-coefs <string> list of basic types of processing required. \n"
178 " Permissable types are: \n" + sigpr_options_supported()+
" \n"
179 "-delta <string> list of delta types of processing required. Basic \n"
180 " processing does not need to be specified for this option to work. \n"
181 " Permissable types are: \n" + sigpr_options_supported()+
" \n"
182 "-acc <string> list of acceleration (delta delta) processing \n"
183 " required. Basic processing does not need to be specified for \n"
184 " this option to work. \n"
185 " Permissable types are: \n"
186 + sigpr_options_supported()+
"\n"
187 "-window_type <string> Type of window used on waveform. \n"
188 " Permissable types are: \n" +
190 " default: "DEFAULT_WINDOW
"\n\n"
191 "-lpc_order <int> Order of lpc analysis. \n\n"
192 "-ref_order <int> Order of lpc reflection coefficient analysis. \n\n"
193 "-cep_order <int> Order of lpc cepstral analysis.\n\n"
194 "-melcep_order <int> Order of Mel cepstral analysis.\n\n"
195 "-fbank_order <int> Order of filter bank analysis.\n\n"
196 "-preemph <float> Perform pre-emphasis with this factor.\n\n"
197 "-lifter <float> lifter coefficient.\n\n"
198 "-usepower use power rather than energy in filter bank \n"
200 "-include_c0 include cepstral coefficient 0\n\n"
201 "-order <string> order of analyses\n", files, al);
206 StringtoStrList(al.
val(
"-coefs"), coef_list);
207 StringtoStrList(al.
val(
"-delta"), delta_list);
208 StringtoStrList(al.
val(
"-acc"), acc_list);
210 StringtoStrList(al.
val(
"-order"), tlist);
211 StrListtoIList(tlist, olist);
213 if (read_wave(sig, files.
first(), al) != read_ok)
219 if (read_track(full, al.
val(
"-pm"), al))
224 full.
resize((
int)ceil(sig.
end() / op.
F(
"frame_shift")), 0);
229 add_channels_to_map(map, coef_list, op, 0);
230 add_channels_to_map(map, delta_list, op, 1);
231 add_channels_to_map(map, acc_list, op, 2);
235 full.
resize(EST_CURRENT, map);
238 pre_emphasis(sig, al.
fval(
"-preemph"));
241 cerr <<
"sig2fv: -usepower currently not supported" << endl;
243 sigpr_base(sig, full, op, coef_list);
244 sigpr_delta(sig, full, op, delta_list);
245 sigpr_acc(sig, full, op, acc_list);
249 cout <<
"-S " << al.
fval(
"-S") << endl;
253 if (full.
save(out_file, al.
val(
"-otype", 0)) != write_ok)
255 cerr <<
"sig2fv: failed to write output to \"" << out_file
271 for (c = clist.head(), o = olist.head(); c && o; c= c->next(), o = o->next())
273 k = clist(c) +
"_order";
281 op.
set(
"frame_shift", DEFAULT_FRAME_SIZE);
282 op.
set(
"frame_factor", DEFAULT_FRAME_FACTOR);
283 op.
set(
"window_type", DEFAULT_WINDOW);
285 op.
set(
"preemph", DEFAULT_PREEMPH);
286 op.
set(
"lifter", DEFAULT_LIFTER);
288 op.
set(
"lpc_order", DEFAULT_LPC_ORDER);
289 op.
set(
"ref_order", DEFAULT_REF_ORDER);
290 op.
set(
"cep_order", DEFAULT_CEP_ORDER);
291 op.
set(
"fbank_order", DEFAULT_FBANK_ORDER);
292 op.
set(
"melcep_order", DEFAULT_MELCEP_ORDER);
294 op.
set(
"max_period", MAXIMUM_PITCH_PERIOD);
295 op.
set(
"min_period", MINIMUM_PITCH_PERIOD);
296 op.
set(
"def_period", DEFAULT_PITCH_PERIOD);
299 op.
set(
"max_period", al.
fval(
"-max_period", 0));
301 op.
set(
"min_period", al.
fval(
"-min_period", 0));
303 op.
set(
"def_period", al.
fval(
"-def_period", 0));
305 if (al.
present(
"-window_type"))
306 op.
set(
"window_type", al.
sval(
"-window_type", 1));
309 op.
set(
"frame_shift", al.
fval(
"-shift", 1));
311 op.
set(
"frame_factor", al.
fval(
"-factor", 1));
313 op.
set(
"frame_factor", op.
F(
"frame_factor")*-1.0*al.
fval(
"-size"));
315 op.
set(
"frame_factor",
316 al.
fval(
"-length", est_errors_allowed)/op.
F(
"frame_shift",est_errors_allowed));
319 op.
set(
"preemph", al.
fval(
"-preemph", 1));
321 op.
set(
"lifter", al.
fval(
"-lifter", 1));
324 op.
set(
"lpc_order", al.
ival(
"-lpc_order", 1));
326 op.
set(
"ref_order", al.
ival(
"-ref_order", 1));
328 op.
set(
"cep_order", al.
ival(
"-cep_order", 1));
329 if (al.
present(
"-fbank_order"))
330 op.
set(
"fbank_order", al.
ival(
"-fbank_order", 1));
331 if (al.
present(
"-melcep_order"))
332 op.
set(
"melcep_order", al.
ival(
"-melcep_order", 1));
335 op.
set(
"usepower", al.
val(
"-usepower", 1));
338 op.
set(
"include_c0", al.
val(
"-include_c0", 1));