gmm-basis-fmllr-training.cc File Reference
#include <string>
#include <vector>
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "gmm/am-diag-gmm.h"
#include "hmm/transition-model.h"
#include "transform/fmllr-diag-gmm.h"
#include "transform/basis-fmllr-diag-gmm.h"
Include dependency graph for gmm-basis-fmllr-training.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 32 of file gmm-basis-fmllr-training.cc.

References AmDiagGmm::Dim(), BasisFmllrEstimate::EstimateFmllrBasis(), ParseOptions::GetArg(), rnnlm::i, KALDI_LOG, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), AmDiagGmm::Read(), ParseOptions::Read(), TransitionModel::Read(), ParseOptions::Register(), Input::Stream(), and kaldi::WriteKaldiObject().

32  {
33  try {
34  typedef kaldi::int32 int32;
35  using namespace kaldi;
36  const char *usage =
37  "Estimate fMLLR basis representation. Reads a set of gradient scatter\n"
38  "accumulations. Outputs basis matrices.\n"
39  "Usage: gmm-basis-fmllr-training [options] <model-in> <basis-wspecifier> "
40  "<accs-in1> <accs-in2> ...\n";
41 
42  bool binary_write = true;
43  ParseOptions po(usage);
44  po.Register("binary", &binary_write, "Write output in binary mode");
45 
46  po.Read(argc, argv);
47  if (po.NumArgs() < 3) {
48  po.PrintUsage();
49  exit(1);
50  }
51 
52  string
53  model_rxfilename = po.GetArg(1),
54  basis_wspecifier = po.GetArg(2);
55 
56  TransitionModel trans_model;
57  AmDiagGmm am_gmm;
58  {
59  bool binary;
60  Input ki(model_rxfilename, &binary);
61  trans_model.Read(ki.Stream(), binary);
62  am_gmm.Read(ki.Stream(), binary);
63  }
64 
65  BasisFmllrAccus basis_accs(am_gmm.Dim());
66  int num_accs = po.NumArgs() - 2;
67 
68  for (int i = 3, max = po.NumArgs(); i <= max; ++i) {
69  std::string accs_in_filename = po.GetArg(i);
70  bool binary_read;
71  kaldi::Input ki(accs_in_filename, &binary_read);
72  basis_accs.Read(ki.Stream(), binary_read, true /* add read values*/);
73  }
74 
75  // Estimate the basis matrices
76  BasisFmllrEstimate basis_est(am_gmm.Dim());
77  basis_est.EstimateFmllrBasis(am_gmm, basis_accs);
78  WriteKaldiObject(basis_est, basis_wspecifier, binary_write);
79 
80  KALDI_LOG << "Summed " << num_accs << " gradient scatter stats";
81  KALDI_LOG << "Generate " << basis_est.BasisSize() << " bases, written to "
82  << basis_wspecifier;
83  return 0;
84  } catch(const std::exception& e) {
85  std::cerr << e.what();
86  return -1;
87  }
88 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
kaldi::int32 int32
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
Stats for fMLLR subspace estimation.
void Read(std::istream &is, bool binary)
int32 Dim() const
Definition: am-diag-gmm.h:79
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
void EstimateFmllrBasis(const AmDiagGmm &am_gmm, const BasisFmllrAccus &basis_accus)
Estimate the base matrices efficiently in a Maximum Likelihood manner.
#define KALDI_LOG
Definition: kaldi-error.h:153
void Read(std::istream &in_stream, bool binary)
Definition: am-diag-gmm.cc:147
Estimation functions for basis fMLLR.