get-full-lda-mat.cc File Reference
Include dependency graph for get-full-lda-mat.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Functions

void IncreaseTransformDimension (int32 new_dimension, Matrix< BaseFloat > *mat)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 54 of file get-full-lda-mat.cc.

References ParseOptions::GetArg(), ParseOptions::GetOptArg(), KALDI_ASSERT, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), ParseOptions::Register(), and kaldi::WriteKaldiObject().

54  {
55  try {
56  using namespace kaldi;
57 
58  const char *usage =
59  "This is a special-purpose program to be used in \"predictive SGMMs\".\n"
60  "It takes in an LDA+MLLT matrix, and the original \"full\" LDA matrix\n"
61  "as output by the --write-full-matrix option of est-lda; and it writes\n"
62  "out a \"full\" LDA+MLLT matrix formed by the LDA+MLLT matrix plus the\n"
63  "remaining rows of the \"full\" LDA matrix; and also writes out its inverse\n"
64  "Usage: get-full-lda-mat [options] <lda-mllt-rxfilename> <full-lda-rxfilename> "
65  "<full-lda-mllt-wxfilename> [<inv-full-lda-mllt-wxfilename>]\n"
66  "E.g.: get-full-lda-mat final.mat full.mat full_lda_mllt.mat full_lda_mllt_inv.mat\n";
67 
68  bool binary = true;
69  ParseOptions po(usage);
70 
71  po.Register("binary", &binary, "Write in binary mode (only relevant if output is a wxfilename)");
72 
73  po.Read(argc, argv);
74 
75  if (po.NumArgs() < 3 || po.NumArgs() > 4) {
76  po.PrintUsage();
77  exit(1);
78  }
79 
80  std::string lda_mllt_rxfilename = po.GetArg(1),
81  full_lda_rxfilename = po.GetArg(2),
82  full_lda_mllt_wxfilename = po.GetArg(3),
83  inv_full_lda_mllt_wxfilename = po.GetOptArg(4);
84 
85  Matrix<BaseFloat> lda_mllt;
86  ReadKaldiObject(lda_mllt_rxfilename, &lda_mllt);
87  Matrix<BaseFloat> full_lda;
88  ReadKaldiObject(full_lda_rxfilename, &full_lda);
89 
90  KALDI_ASSERT(full_lda.NumCols() == lda_mllt.NumCols());
91  KALDI_ASSERT(full_lda.NumRows() == full_lda.NumCols());
92 
93  Matrix<BaseFloat> full_lda_mllt(full_lda);
94  full_lda_mllt.Range(0, lda_mllt.NumRows(),
95  0, lda_mllt.NumCols()).CopyFromMat(lda_mllt);
96 
97  WriteKaldiObject(full_lda_mllt, full_lda_mllt_wxfilename, binary);
98 
99  if (po.NumArgs() != 3) {
100  full_lda_mllt.Invert();
101  WriteKaldiObject(full_lda_mllt, inv_full_lda_mllt_wxfilename, binary);
102  }
103  return 0;
104  } catch(const std::exception &e) {
105  std::cerr << e.what();
106  return -1;
107  }
108 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
Definition: kaldi-matrix.h:67
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257