sum-lda-accs.cc
Go to the documentation of this file.
1 // bin/sum-lda-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 "gmm/mle-am-diag-gmm.h"
22 #include "transform/lda-estimate.h"
23 
24 
25 int main(int argc, char *argv[]) {
26  try {
27  using namespace kaldi;
28  typedef kaldi::int32 int32;
29 
30  const char *usage =
31  "Sum stats obtained with acc-lda.\n"
32  "Usage: sum-lda-accs [options] <stats-out> <stats-in1> <stats-in2> ...\n";
33 
34  bool binary = true;
35  ParseOptions po(usage);
36  po.Register("binary", &binary, "Write accumulators in binary mode.");
37  po.Read(argc, argv);
38 
39  if (po.NumArgs() < 2) {
40  po.PrintUsage();
41  exit(1);
42  }
43 
44  LdaEstimate lda;
45  std::string stats_out_filename = po.GetArg(1);
46 
47  for (int32 i = 2; i <= po.NumArgs(); i++) {
48  bool binary_in, add = true;
49  Input ki(po.GetArg(i), &binary_in);
50  lda.Read(ki.Stream(), binary_in, add);
51  }
52 
53  Output ko(stats_out_filename, binary);
54  lda.Write(ko.Stream(), binary);
55  return 0;
56  } catch(const std::exception &e) {
57  std::cerr << e.what();
58  return -1;
59  }
60 }
61 
62 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
Class for computing linear discriminant analysis (LDA) transform.
Definition: lda-estimate.h:57
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Write(std::ostream &out_stream, bool binary) const
kaldi::int32 int32
int main(int argc, char *argv[])
Definition: sum-lda-accs.cc:25
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
void Read(std::istream &in_stream, bool binary, bool add)
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
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).