copy-transition-model.cc File Reference
#include "hmm/transition-model.h"
#include "fst/fstlib.h"
#include "util/common-utils.h"
Include dependency graph for copy-transition-model.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 25 of file copy-transition-model.cc.

References ParseOptions::GetArg(), KALDI_LOG, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), kaldi::ReadKaldiObject(), ParseOptions::Register(), and kaldi::WriteKaldiObject().

25  {
26  try {
27  using namespace kaldi;
28  typedef kaldi::int32 int32;
29  using fst::SymbolTable;
30  using fst::VectorFst;
31  using fst::StdArc;
32 
33  const char *usage =
34  "Copies a transition model (this can be used to separate transition \n"
35  " models from the acoustic models they are written with.\n"
36  "Usage: copy-transition-model [options] <transition-model or model file> <transition-model-out>\n"
37  "e.g.: \n"
38  " copy-transition-model --binary=false 1.mdl 1.txt\n";
39 
40  bool binary;
41 
42  ParseOptions po(usage);
43 
44  po.Register("binary", &binary, "Write output in binary mode.");
45 
46  po.Read(argc, argv);
47 
48  if (po.NumArgs() != 2) {
49  po.PrintUsage();
50  exit(1);
51  }
52 
53  std::string transition_model_rxfilename = po.GetArg(1),
54  transition_model_wxfilename = po.GetArg(2);
55 
56 
57  TransitionModel trans_model;
58  ReadKaldiObject(transition_model_rxfilename, &trans_model);
59 
60  WriteKaldiObject(trans_model, transition_model_wxfilename, binary);
61 
62  KALDI_LOG << "Copied transition model.";
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
fst::StdArc StdArc
kaldi::int32 int32
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
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
Definition: kaldi-io.h:257
#define KALDI_LOG
Definition: kaldi-error.h:153