All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gmm-global-sum-accs.cc File Reference
#include "util/common-utils.h"
#include "gmm/full-gmm.h"
#include "gmm/mle-full-gmm.h"
Include dependency graph for gmm-global-sum-accs.cc:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 24 of file gmm-global-sum-accs.cc.

References ParseOptions::GetArg(), rnnlm::i, KALDI_LOG, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), AccumDiagGmm::Read(), ParseOptions::Register(), Output::Stream(), Input::Stream(), and AccumDiagGmm::Write().

24  {
25  try {
26  typedef kaldi::int32 int32;
27 
28  const char *usage =
29  "Sum multiple accumulated stats files for diagonal-covariance GMM "
30  "training.\n"
31  "Usage: gmm-global-sum-accs [options] stats-out stats-in1 stats-in2 ...\n";
32 
33  bool binary = true;
34  kaldi::ParseOptions po(usage);
35  po.Register("binary", &binary, "Write output in binary mode");
36  po.Read(argc, argv);
37 
38  if (po.NumArgs() < 2) {
39  po.PrintUsage();
40  exit(1);
41  }
42 
43  std::string stats_out_filename = po.GetArg(1);
44  kaldi::AccumDiagGmm gmm_accs;
45 
46  for (int i = 2, max = po.NumArgs(); i <= max; i++) {
47  std::string stats_in_filename = po.GetArg(i);
48  bool binary_read;
49  kaldi::Input ki(stats_in_filename, &binary_read);
50  gmm_accs.Read(ki.Stream(), binary_read, true /*add read values*/);
51  }
52 
53  // Write out the accs
54  {
55  kaldi::Output ko(stats_out_filename, binary);
56  gmm_accs.Write(ko.Stream(), binary);
57  }
58 
59  KALDI_LOG << "Written stats to " << stats_out_filename;
60  } catch(const std::exception &e) {
61  std::cerr << e.what() << '\n';
62  return -1;
63  }
64 }
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)
Definition: mle-diag-gmm.cc:33
#define KALDI_LOG
Definition: kaldi-error.h:133
void Write(std::ostream &out_stream, bool binary) const
Definition: mle-diag-gmm.cc:77