fmpe-est.cc
Go to the documentation of this file.
1 // featbin/fmpe-est.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  "Do one iteration of learning (modified gradient descent)\n"
29  "on fMPE transform\n"
30  "Usage: fmpe-est [options...] <fmpe-in> <stats-in> <fmpe-out>\n"
31  "E.g. fmpe-est 1.fmpe 1.accs 2.fmpe\n";
32 
33  ParseOptions po(usage);
34  FmpeUpdateOptions opts;
35  bool binary = true;
36  po.Register("binary", &binary, "If true, output fMPE object in "
37  "binary mode.");
38  opts.Register(&po);
39  po.Read(argc, argv);
40 
41  if (po.NumArgs() != 3) {
42  po.PrintUsage();
43  exit(1);
44  }
45 
46  std::string fmpe_rxfilename = po.GetArg(1),
47  stats_rxfilename = po.GetArg(2),
48  fmpe_wxfilename = po.GetArg(3);
49 
50  Fmpe fmpe;
51  ReadKaldiObject(fmpe_rxfilename, &fmpe);
52  FmpeStats stats;
53  ReadKaldiObject(stats_rxfilename, &stats);
54 
55  stats.DoChecks(); // checks certain checksums.
56  fmpe.Update(opts, stats);
57 
58  WriteKaldiObject(fmpe, fmpe_wxfilename, binary);
59 
60  KALDI_LOG << "Updated fMPE object and wrote to "
61  << fmpe_wxfilename;
62  return 0;
63  } catch(const std::exception &e) {
64  std::cerr << e.what();
65  return -1;
66  }
67 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
BaseFloat Update(const FmpeUpdateOptions &config, const FmpeStats &stats)
Definition: fmpe.cc:443
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
void Register(OptionsItf *opts)
Definition: fmpe.h:95
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
int main(int argc, char *argv[])
Definition: fmpe-est.cc:24
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void DoChecks()
Definition: fmpe.cc:649
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).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:153