All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gmm-init-trans.cc File Reference
Include dependency graph for gmm-init-trans.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file gmm-init-trans.cc.

References ParseOptions::GetArg(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), ParseOptions::Register(), Output::Stream(), AmDiagGmm::Write(), and TransitionModel::Write().

28  {
29  try {
30  using namespace kaldi;
31  using kaldi::int32;
32 
33  const char *usage =
34  "Initialize transition model given topo, tree and GMM (used for format conversion from HTK)\n"
35  "Usage: gmm-init-trans <topology-in> <gmm-in> <tree-in> <model-out>\n";
36 
37  bool binary = true;
38  ParseOptions po(usage);
39  po.Register("binary", &binary, "Write output in binary mode");
40  po.Read(argc, argv);
41 
42  if (po.NumArgs() != 4) {
43  po.PrintUsage();
44  exit(1);
45  }
46 
47  std::string topo_filename = po.GetArg(1);
48  std::string gmm_filename = po.GetArg(2);
49  std::string tree_filename = po.GetArg(3);
50  std::string model_out_filename = po.GetArg(4);
51 
52  // Read toppology.
53  HmmTopology topo;
54  ReadKaldiObject(topo_filename, &topo);
55 
56  // Read model.
57  AmDiagGmm am_gmm;
58  ReadKaldiObject(gmm_filename, &am_gmm);
59 
60  // Now the tree
61  ContextDependency ctx_dep;
62  ReadKaldiObject(tree_filename, &ctx_dep);
63 
64  TransitionModel trans_model(ctx_dep, topo);
65 
66  { // Write transition-model and GMM to one file in the normal Kaldi way.
67  Output out(model_out_filename, binary);
68  trans_model.Write(out.Stream(), binary);
69  am_gmm.Write(out.Stream(), binary);
70  }
71 
72  return 0;
73  } catch(const std::exception &e) {
74  std::cerr << e.what();
75  return -1;
76  }
77 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
A class for storing topology information for phones.
Definition: hmm-topology.h:94
void Write(std::ostream &out_stream, bool binary) const
Definition: am-diag-gmm.cc:163
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
Definition: kaldi-io.cc:818
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36