gmm-init-lvtln.cc
Go to the documentation of this file.
1 // gmmbin/gmm-init-lvtln.cc
2 
3 // Copyright 2009-2011 Microsoft Corporation
4 // 2014 Johns Hopkins University (author: Daniel Povey)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 
22 #include "base/kaldi-common.h"
23 #include "util/common-utils.h"
24 #include "transform/lvtln.h"
25 
26 
27 int main(int argc, char *argv[]) {
28  try {
29  using namespace kaldi;
30  using kaldi::int32;
31 
32  const char *usage =
33  "Initialize lvtln transforms\n"
34  "Usage: gmm-init-lvtln [options] <lvtln-out>\n"
35  "e.g.: \n"
36  " gmm-init-lvtln --dim=13 --num-classes=21 --default-class=10 1.lvtln\n";
37 
38  bool binary = true;
39  int32 dim = 13;
40  int32 default_class = 10;
41  int32 num_classes = 21;
42 
43  ParseOptions po(usage);
44  po.Register("binary", &binary, "Write output in binary mode");
45  po.Register("dim", &dim, "feature dimension");
46  po.Register("num-classes", &num_classes, "Number of transforms to be trained");
47  po.Register("default-class", &default_class, "Index of default transform, "
48  "to be used if no data is available for training");
49 
50  po.Read(argc, argv);
51 
52  if (po.NumArgs() != 1) {
53  po.PrintUsage();
54  exit(1);
55  }
56 
57  std::string lvtln_wxfilename = po.GetArg(1);
58 
59  // We'll set the transforms separately using gmm-train-lvtln-special
60  LinearVtln lvtln(dim, num_classes, default_class);
61  WriteKaldiObject(lvtln, lvtln_wxfilename, binary);
62 
63  KALDI_LOG << "Initialized LVTLN object and wrote it to "
64  << PrintableWxfilename(lvtln_wxfilename);
65  return 0;
66  } catch(const std::exception &e) {
67  std::cerr << e.what();
68  return -1;
69  }
70 }
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].
kaldi::int32 int32
int main(int argc, char *argv[])
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
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
std::string PrintableWxfilename(const std::string &wxfilename)
PrintableWxfilename turns the wxfilename into a more human-readable form for error reporting...
Definition: kaldi-io.cc:73
#define KALDI_LOG
Definition: kaldi-error.h:153