All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fstminimizeencoded.cc File Reference
#include "base/kaldi-common.h"
#include "util/kaldi-io.h"
#include "util/parse-options.h"
#include "util/text-utils.h"
#include "fst/fstlib.h"
#include "fstext/determinize-star.h"
#include "fstext/fstext-utils.h"
#include "fstext/kaldi-fst-io.h"
Include dependency graph for fstminimizeencoded.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 35 of file fstminimizeencoded.cc.

References ParseOptions::GetOptArg(), fst::MinimizeEncoded(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), fst::ReadFstKaldi(), ParseOptions::Register(), and fst::WriteFstKaldi().

35  {
36  try {
37  using namespace kaldi;
38  using namespace fst;
39  using kaldi::int32;
40 
41  const char *usage =
42  "Minimizes FST after encoding [similar to fstminimize, but no weight-pushing]\n"
43  "\n"
44  "Usage: fstminimizeencoded [in.fst [out.fst] ]\n";
45 
46  float delta = kDelta;
47  ParseOptions po(usage);
48  po.Register("delta", &delta, "Delta likelihood used for quantization of weights");
49  po.Read(argc, argv);
50 
51  if (po.NumArgs() > 2) {
52  po.PrintUsage();
53  exit(1);
54  }
55 
56  std::string fst_in_filename = po.GetOptArg(1),
57  fst_out_filename = po.GetOptArg(2);
58 
59  VectorFst<StdArc> *fst = ReadFstKaldi(fst_in_filename);
60 
61  MinimizeEncoded(fst, delta);
62 
63  WriteFstKaldi(*fst, fst_out_filename);
64 
65  delete fst;
66  return 0;
67  } catch(const std::exception &e) {
68  std::cerr << e.what();
69  return -1;
70  }
71  return 0;
72 }
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
Definition: graph.dox:21
void MinimizeEncoded(VectorFst< Arc > *fst, float delta=kDelta)
Definition: fstext-utils.h:114
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)