fmpe-init.cc
Go to the documentation of this file.
1 // featbin/fmpe-init.cc
2 
3 // Copyright 2012 Johns Hopkins University (Author: Daniel Povey) Yanmin Qian
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 "base/kaldi-common.h"
21 #include "util/common-utils.h"
22 #include "transform/fmpe.h"
23 
24 int main(int argc, char *argv[]) {
25  using namespace kaldi;
26  try {
27  const char *usage =
28  "Initialize fMPE transform (to zero)\n"
29  "Usage: fmpe-init [options...] <diag-gmm-in> <fmpe-out>\n"
30  "E.g. fmpe-init 1.ubm 1.fmpe\n";
31 
32  ParseOptions po(usage);
33  FmpeOptions opts;
34  bool binary = true;
35  po.Register("binary", &binary, "If true, output fMPE object in binary mode.");
36  opts.Register(&po);
37  po.Read(argc, argv);
38 
39  if (po.NumArgs() != 2) {
40  po.PrintUsage();
41  exit(1);
42  }
43 
44  std::string dgmm_rxfilename = po.GetArg(1),
45  fmpe_wxfilename = po.GetArg(2);
46 
47  DiagGmm dgmm;
48  ReadKaldiObject(dgmm_rxfilename, &dgmm);
49 
50 
51  Fmpe fmpe(dgmm, opts);
52 
53  Output ko(fmpe_wxfilename, binary);
54  fmpe.Write(ko.Stream(), binary);
55 
56  KALDI_LOG << "Initialized fMPE object and wrote to "
57  << fmpe_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
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:832
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 Register(OptionsItf *opts)
Definition: fmpe.h:75
int main(int argc, char *argv[])
Definition: fmpe-init.cc:24
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).
Definition for Gaussian Mixture Model with diagonal covariances.
Definition: diag-gmm.h:42
#define KALDI_LOG
Definition: kaldi-error.h:153
void Write(std::ostream &os, bool binary) const
Definition: fmpe.cc:500