fmpe-sum-accs.cc File Reference
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "transform/fmpe.h"
Include dependency graph for fmpe-sum-accs.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 24 of file fmpe-sum-accs.cc.

References ParseOptions::GetArg(), KALDI_LOG, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), FmpeStats::Read(), ParseOptions::Register(), Input::Stream(), and kaldi::WriteKaldiObject().

24  {
25  using namespace kaldi;
26  using kaldi::int32;
27  try {
28  const char *usage =
29  "Sum fMPE stats\n"
30  "Usage: fmpe-sum-accs [options...] <accs-out> <stats-in1> <stats-in2> ... \n"
31  "E.g. fmpe-sum-accs 1.accs 1.1.accs 1.2.accs 1.3.accs 1.4.accs\n";
32 
33  ParseOptions po(usage);
34  bool binary = true;
35  po.Register("binary", &binary, "If true, output fMPE stats in "
36  "binary mode.");
37  po.Read(argc, argv);
38 
39  if (po.NumArgs() < 2) {
40  po.PrintUsage();
41  exit(1);
42  }
43 
44  std::string stats_wxfilename = po.GetArg(1);
45 
46  FmpeStats stats;
47  for (int32 arg = 2; arg <= po.NumArgs(); arg++) {
48  std::string stats_rxfilename = po.GetArg(arg);
49  bool binary;
50  Input ki(stats_rxfilename, &binary);
51  stats.Read(ki.Stream(), binary, true); // true == sum accs.
52  }
53 
54  WriteKaldiObject(stats, stats_wxfilename, binary);
55 
56  KALDI_LOG << "Summed " << (po.NumArgs()-1) << " fMPE stats and wrote to "
57  << stats_wxfilename;
58  return 0;
59  } catch(const std::exception &e) {
60  std::cerr << e.what();
61  return -1;
62  }
63 }
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
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:153
void Read(std::istream &is, bool binary, bool add=false)
Definition: fmpe.cc:685