294 using namespace kaldi;
296 "This is a rather special-purpose program which processes 2-dimensional\n" 297 "features consisting of (prob-of-voicing, pitch). By default we do model-based\n" 298 "pitch smoothing and interpolation (see code), or if --linear-interpolation=true,\n" 299 "just linear interpolation across gaps where pitch == 0 (not predicted).\n" 300 "Usage: interpolate-pitch [options...] <feats-rspecifier> <feats-wspecifier>\n";
306 bool linear_interpolation =
false;
309 opts.
Register(
"linear-interpolation",
310 &linear_interpolation,
"If true, just do simple linear " 311 "interpolation across gaps (else, model-based)");
315 opts.Read(argc, argv);
317 if (opts.NumArgs() != 2) {
322 std::string input_rspecifier = opts.GetArg(1);
323 std::string output_wspecifier = opts.GetArg(2);
328 if (!kaldi_writer.
Open(output_wspecifier))
329 KALDI_ERR <<
"Could not initialize output with wspecifier " 330 << output_wspecifier;
332 int32 num_done = 0, num_err = 0;
335 for (; !reader.Done(); reader.Next()) {
336 std::string utt = reader.Key();
338 int num_frames = features.
NumRows();
340 if (num_frames == 0 && features.
NumCols() != 2) {
352 kaldi_writer.
Write(utt, features);
355 if (num_done % 10 == 0)
356 KALDI_LOG <<
"Processed " << num_done <<
" utterances";
357 KALDI_VLOG(2) <<
"Processed features for key " << utt;
359 if (!linear_interpolation) stats.
Print();
360 KALDI_LOG <<
"Done " << num_done <<
" utterances, " << num_err
362 return (num_done != 0 ? 0 : 1);
363 }
catch(
const std::exception &e) {
364 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool Open(const std::string &wspecifier)
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
A templated class for writing objects to an archive or script file; see The Table concept...
void Register(OptionsItf *opts)
void LinearlyInterpolatePitch(Matrix< BaseFloat > *mat)
void Write(const std::string &key, const T &value) const
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).