sgmm2-copy.cc File Reference
Include dependency graph for sgmm2-copy.cc:

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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

Definition at line 28 of file sgmm2-copy.cc.

References ParseOptions::GetArg(), KALDI_LOG, kaldi::kSgmmWriteAll, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), TransitionModel::Read(), AmSgmm2::Read(), ParseOptions::Register(), Output::Stream(), Input::Stream(), TransitionModel::Write(), and AmSgmm2::Write().

28  {
29  try {
30  using namespace kaldi;
31  typedef kaldi::int32 int32;
32  const char *usage =
33  "Copy SGMM (possibly changing binary/text format)\n"
34  "Usage: sgmm2-copy [options] <model-in> <model-out>\n"
35  "e.g.: sgmm2-copy --binary=false 1.mdl 1_text.mdl\n";
36 
37  bool binary_write = true;
38 
39  ParseOptions po(usage);
40  po.Register("binary", &binary_write, "Write output in binary mode");
41 
42  po.Read(argc, argv);
43  if (po.NumArgs() != 2) {
44  po.PrintUsage();
45  exit(1);
46  }
47  std::string model_in_filename = po.GetArg(1),
48  model_out_filename = po.GetArg(2);
49 
50  AmSgmm2 am_sgmm;
51  TransitionModel trans_model;
52  {
53  bool binary;
54  Input ki(model_in_filename, &binary);
55  trans_model.Read(ki.Stream(), binary);
56  am_sgmm.Read(ki.Stream(), binary);
57  }
58 
59  {
60  Output ko(model_out_filename, binary_write);
61  trans_model.Write(ko.Stream(), binary_write);
62  am_sgmm.Write(ko.Stream(), binary_write, kSgmmWriteAll);
63  }
64 
65 
66  KALDI_LOG << "Written model to " << model_out_filename;
67  return 0;
68  } catch(const std::exception &e) {
69  std::cerr << e.what();
70  return -1;
71  }
72 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void Write(std::ostream &os, bool binary, SgmmWriteFlagsType write_params) const
Definition: am-sgmm2.cc:203
Class for definition of the subspace Gmm acoustic model.
Definition: am-sgmm2.h:231
void Read(std::istream &is, bool binary)
Definition: am-sgmm2.cc:89
kaldi::int32 int32
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void Read(std::istream &is, bool binary)
void Write(std::ostream &os, bool binary) const
#define KALDI_LOG
Definition: kaldi-error.h:153