est-lda.cc File Reference
Include dependency graph for est-lda.cc:

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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

Definition at line 25 of file est-lda.cc.

References LdaEstimate::Estimate(), ParseOptions::GetArg(), rnnlm::i, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), LdaEstimate::Read(), ParseOptions::Read(), LdaEstimateOptions::Register(), ParseOptions::Register(), Output::Stream(), MatrixBase< Real >::Write(), and kaldi::WriteKaldiObject().

25  {
26  using namespace kaldi;
27  typedef kaldi::int32 int32;
28  try {
29  const char *usage =
30  "Estimate LDA transform using stats obtained with acc-lda.\n"
31  "Usage: est-lda [options] <lda-matrix-out> <lda-acc-1> <lda-acc-2> ...\n";
32 
33  bool binary = true;
34  std::string full_matrix_wxfilename;
35  LdaEstimateOptions opts;
36  ParseOptions po(usage);
37  po.Register("binary", &binary, "Write matrix in binary mode.");
38  po.Register("write-full-matrix", &full_matrix_wxfilename,
39  "Write full LDA matrix to this location.");
40  opts.Register(&po);
41  po.Read(argc, argv);
42 
43  if (po.NumArgs() < 2) {
44  po.PrintUsage();
45  exit(1);
46  }
47 
48  LdaEstimate lda;
49  std::string lda_mat_wxfilename = po.GetArg(1);
50 
51  for (int32 i = 2; i <= po.NumArgs(); i++) {
52  bool binary_in, add = true;
53  Input ki(po.GetArg(i), &binary_in);
54  lda.Read(ki.Stream(), binary_in, add);
55  }
56 
57  Matrix<BaseFloat> lda_mat;
58  Matrix<BaseFloat> full_lda_mat;
59  lda.Estimate(opts, &lda_mat, &full_lda_mat);
60  WriteKaldiObject(lda_mat, lda_mat_wxfilename, binary);
61  if (full_matrix_wxfilename != "") {
62  Output ko(full_matrix_wxfilename, binary);
63  full_lda_mat.Write(ko.Stream(), binary);
64  }
65  return 0;
66  } catch(const std::exception &e) {
67  std::cerr << e.what();
68  return -1;
69  }
70 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Write(std::ostream &out, bool binary) const
write to stream.
Class for computing linear discriminant analysis (LDA) transform.
Definition: lda-estimate.h:57
kaldi::int32 int32
void Estimate(const LdaEstimateOptions &opts, Matrix< BaseFloat > *M, Matrix< BaseFloat > *Mfull=NULL) const
Estimates the LDA transform matrix m.
Definition: lda-estimate.cc:85
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Read(std::istream &in_stream, bool binary, bool add)
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
void Register(OptionsItf *opts)
Definition: lda-estimate.h:38