24 int main(
int argc,
char *argv[]) {
25 using namespace kaldi;
29 "Compute statistics for fMPE training\n" 30 "Usage: fmpe-acc-stats [options...] <fmpe-object> " 31 "<feat-rspecifier> <feat-diff-rspecifier> <gselect-rspecifier> <stats-out>\n" 32 "Note: gmm-fmpe-acc-stats avoids computing the features an extra time\n";
36 po.
Register(
"binary", &binary,
"If true, output stats in binary mode.");
44 std::string fmpe_rxfilename = po.
GetArg(1),
45 feat_rspecifier = po.
GetArg(2),
46 feat_diff_rspecifier = po.
GetArg(3),
47 gselect_rspecifier = po.
GetArg(4),
48 stats_wxfilename = po.
GetArg(5);
60 int32 num_done = 0, num_err = 0;
62 for (; !feat_reader.
Done(); feat_reader.
Next()) {
63 std::string key = feat_reader.
Key();
65 if (!gselect_reader.
HasKey(key)) {
66 KALDI_WARN <<
"No gselect information for key " << key;
70 const std::vector<std::vector<int32> > &gselect =
71 gselect_reader.
Value(key);
72 if (static_cast<int32>(gselect.size()) != feat_in.NumRows()) {
73 KALDI_WARN <<
"gselect information has wrong size";
77 if (!diff_reader.
HasKey(key)) {
78 KALDI_WARN <<
"No gradient information for key " << key;
84 if (feat_deriv.
NumCols() == feat_in.NumCols()) {
85 fmpe.
AccStats(feat_in, gselect, feat_deriv, NULL, &fmpe_stats);
86 }
else if (feat_deriv.
NumCols() == feat_in.NumCols() * 2) {
88 0, feat_in.NumCols()),
89 indirect_deriv(feat_deriv, 0, feat_deriv.
NumRows(),
90 feat_in.NumCols(), feat_in.NumCols());
91 fmpe.
AccStats(feat_in, gselect, direct_deriv, &indirect_deriv, &fmpe_stats);
93 KALDI_ERR <<
"Mismatch in dimension of feature derivative.";
98 KALDI_LOG <<
" Done " << num_done <<
" utterances, " << num_err
103 return (num_done != 0 ? 0 : 1);
104 }
catch(
const std::exception &e) {
105 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int main(int argc, char *argv[])
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
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).
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Sub-matrix representation.
void AccStats(const MatrixBase< BaseFloat > &feat_in, const std::vector< std::vector< int32 > > &gselect, const MatrixBase< BaseFloat > &direct_feat_deriv, const MatrixBase< BaseFloat > *indirect_feat_deriv, FmpeStats *stats) const