sum-mllt-accs.cc
Go to the documentation of this file.
1 // bin/sum-mllt-accs.cc
2 
3 // Copyright 2014 LINSE/UFSC; Augusto Henrique Hentz
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 #include "util/common-utils.h"
21 #include "transform/mllt.h"
22 
23 int main(int argc, char *argv[]) {
24  try {
25  using namespace kaldi;
26  typedef kaldi::int32 int32;
27 
28  const char *usage =
29  "Sum stats obtained with gmm-acc-mllt.\n"
30  "Usage: sum-mllt-accs [options] <stats-out> <stats-in1> <stats-in2> ...\n";
31 
32  bool binary = true;
33  ParseOptions po(usage);
34  po.Register("binary", &binary, "Write accumulators in binary mode.");
35  po.Read(argc, argv);
36 
37  if (po.NumArgs() < 2) {
38  po.PrintUsage();
39  exit(1);
40  }
41 
42  MlltAccs mllt_accs;
43  std::string stats_out_filename = po.GetArg(1);
44 
45  for (int32 i = 2; i <= po.NumArgs(); i++) {
46  bool binary_in, add = true;
47  Input ki(po.GetArg(i), &binary_in);
48  mllt_accs.Read(ki.Stream(), binary_in, add);
49  }
50 
51  Output ko(stats_out_filename, binary);
52  mllt_accs.Write(ko.Stream(), binary);
53  return 0;
54  } catch(const std::exception &e) {
55  std::cerr << e.what();
56  return -1;
57  }
58 }
59 
60 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Read(std::istream &is, bool binary, bool add=false)
Definition: mllt.cc:34
kaldi::int32 int32
void Register(const std::string &name, bool *ptr, const std::string &doc)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
std::ostream & Stream()
Definition: kaldi-io.cc:701
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
int main(int argc, char *argv[])
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void Write(std::ostream &os, bool binary) const
Definition: mllt.cc:51
A class for estimating Maximum Likelihood Linear Transform, also known as global Semi-tied Covariance...
Definition: mllt.h:42