All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
make-pdf-to-tid-transducer.cc File Reference
#include "hmm/transition-model.h"
#include "hmm/hmm-utils.h"
#include "util/common-utils.h"
#include "fst/fstlib.h"
Include dependency graph for make-pdf-to-tid-transducer.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 25 of file make-pdf-to-tid-transducer.cc.

References ParseOptions::GetArg(), ParseOptions::GetOptArg(), kaldi::GetPdfToTransitionIdTransducer(), KALDI_ERR, ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), and kaldi::ReadKaldiObject().

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  "Make transducer from pdfs to transition-ids\n"
35  "Usage: make-pdf-to-tid-transducer model-filename [fst-out]\n"
36  "e.g.: \n"
37  " make-pdf-to-tid-transducer 1.mdl > pdf2tid.fst\n";
38  ParseOptions po(usage);
39 
40  po.Read(argc, argv);
41 
42  if (po.NumArgs() <1 || po.NumArgs() > 2) {
43  po.PrintUsage();
44  exit(1);
45  }
46 
47  std::string trans_model_filename = po.GetArg(1);
48  std::string fst_out_filename = po.GetOptArg(2);
49 
50  TransitionModel trans_model;
51  ReadKaldiObject(trans_model_filename, &trans_model);
52 
53  fst::VectorFst<fst::StdArc> *fst = GetPdfToTransitionIdTransducer(trans_model);
54 
55 #if _MSC_VER
56  if (fst_out_filename == "")
57  _setmode(_fileno(stdout), _O_BINARY);
58 #endif
59 
60  if (!fst->Write(fst_out_filename))
61  KALDI_ERR << "Error writing fst to "
62  << (fst_out_filename == "" ? "standard output" : fst_out_filename);
63  delete fst;
64  } catch(const std::exception &e) {
65  std::cerr << e.what();
66  return -1;
67  }
68 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
Definition: graph.dox:21
fst::StdArc StdArc
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
#define KALDI_ERR
Definition: kaldi-error.h:127
fst::VectorFst< fst::StdArc > * GetPdfToTransitionIdTransducer(const TransitionModel &trans_model)
Returns a transducer from pdfs plus one (input) to transition-ids (output).
Definition: hmm-utils.cc:373