24 int main(
int argc,
char *argv[]) {
25 using namespace kaldi;
29 "Apply fMPE transform to features\n" 30 "Usage: fmpe-apply-transform [options...] <fmpe-object> " 31 "<feat-rspecifier> <gselect-rspecifier> <feat-wspecifier>\n";
34 bool add_to_features =
true;
35 po.
Register(
"add-to-features", &add_to_features,
"If true, add original " 36 "features to fMPE offsets (false useful for diagnostics)");
45 std::string fmpe_rxfilename = po.
GetArg(1),
46 feat_rspecifier = po.
GetArg(2),
47 gselect_rspecifier = po.
GetArg(3),
48 feat_wspecifier = po.
GetArg(4);
57 int32 num_done = 0, num_err = 0;
59 for (; !feat_reader.
Done(); feat_reader.
Next()) {
60 std::string key = feat_reader.
Key();
62 if (!gselect_reader.
HasKey(key)) {
63 KALDI_WARN <<
"No gselect information for key " << key;
67 const std::vector<std::vector<int32> > &gselect =
68 gselect_reader.
Value(key);
69 if (static_cast<int32>(gselect.size()) != feat_in.NumRows()) {
70 KALDI_WARN <<
"gselect information has wrong size";
77 feat_out.AddMat(1.0, feat_in,
kNoTrans);
79 feat_writer.
Write(key, feat_out);
82 KALDI_LOG <<
" Done " << num_done <<
" utterances, " << num_err
84 return (num_done != 0 ? 0 : 1);
85 }
catch(
const std::exception &e) {
86 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ComputeFeatures(const MatrixBase< BaseFloat > &feat_in, const std::vector< std::vector< int32 > > &gselect, Matrix< BaseFloat > *feat_out) const
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Allows random access to a collection of objects in an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
const T & Value(const std::string &key)
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.
bool HasKey(const std::string &key)
int NumArgs() const
Number of positional parameters (c.f. argc-1).