27 int main(
int argc,
char *argv[]) {
29 using namespace kaldi;
31 "Apply Kaldi pitch extractor, starting from wav input. Output is 2-dimensional\n" 32 "features consisting of (NCCF, pitch in Hz), where NCCF is between -1 and 1, and\n" 33 "higher for voiced frames. You will typically pipe this into\n" 34 "process-kaldi-pitch-feats.\n" 35 "Usage: compute-kaldi-pitch-feats [options...] <wav-rspecifier> <feats-wspecifier>\n" 37 "compute-kaldi-pitch-feats --sample-frequency=8000 scp:wav.scp ark:- \n" 39 "See also: process-kaldi-pitch-feats, compute-and-process-kaldi-pitch-feats\n";
57 std::string wav_rspecifier = po.
GetArg(1),
58 feat_wspecifier = po.
GetArg(2);
63 int32 num_done = 0, num_err = 0;
64 for (; !wav_reader.
Done(); wav_reader.
Next()) {
65 std::string utt = wav_reader.
Key();
75 KALDI_WARN <<
"Channel not specified but you have data with " 76 << num_chan <<
" channels; defaulting to zero";
78 if (this_chan >= num_chan) {
79 KALDI_WARN <<
"File with id " << utt <<
" has " 80 << num_chan <<
" channels but you specified channel " 81 << channel <<
", producing no output.";
88 KALDI_ERR <<
"Sample frequency mismatch: you specified " 89 << pitch_opts.
samp_freq <<
" but data has " 90 << wave_data.
SampFreq() <<
" (use --sample-frequency " 91 <<
"option). Utterance is " << utt;
99 KALDI_WARN <<
"Failed to compute pitch for utterance " 105 feat_writer.
Write(utt, features);
106 if (num_done % 50 == 0 && num_done != 0)
107 KALDI_VLOG(2) <<
"Processed " << num_done <<
" utterances";
110 KALDI_LOG <<
"Done " << num_done <<
" utterances, " << num_err
112 return (num_done != 0 ? 0 : 1);
113 }
catch(
const std::exception &e) {
114 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void ComputeKaldiPitch(const PitchExtractionOptions &opts, const VectorBase< BaseFloat > &wave, Matrix< BaseFloat > *output)
This function extracts (pitch, NCCF) per frame, using the pitch extraction method described in "A Pit...
int main(int argc, char *argv[])
A templated class for writing objects to an archive or script file; see The Table concept...
BaseFloat SampFreq() const
const Matrix< BaseFloat > & Data() const
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...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
This class's purpose is to read in Wave files.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...