fstpushspecial.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/fstext-utils.h"
#include "fstext/push-special.h"
#include "fstext/kaldi-fst-io.h"
Include dependency graph for fstpushspecial.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 30 of file fstpushspecial.cc.

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

30  {
31  try {
32  using namespace kaldi;
33  using namespace fst;
34  using kaldi::int32;
35 
36  const char *usage =
37  "Pushes weights in an FST such that all the states\n"
38  "in the FST have arcs and final-probs with weights that\n"
39  "sum to the same amount (viewed as being in the log semiring).\n"
40  "Thus, the \"extra weight\" is distributed throughout the FST.\n"
41  "Tolerance parameter --delta controls how exact this is, and the\n"
42  "speed.\n"
43  "\n"
44  "Usage: fstpushspecial [options] [in.fst [out.fst] ]\n";
45 
46  BaseFloat delta = kDelta;
47  ParseOptions po(usage);
48  po.Register("delta", &delta, "Delta cost: after pushing, all states will "
49  "have a total weight that differs from the average by no more "
50  "than this.");
51  po.Read(argc, argv);
52 
53  if (po.NumArgs() > 2) {
54  po.PrintUsage();
55  exit(1);
56  }
57 
58  std::string fst_in_filename = po.GetOptArg(1),
59  fst_out_filename = po.GetOptArg(2);
60 
61  VectorFst<StdArc> *fst = ReadFstKaldi(fst_in_filename);
62 
63  PushSpecial(fst, delta);
64 
65  WriteFstKaldi(*fst, fst_out_filename);
66  delete fst;
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
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
kaldi::int32 int32
float BaseFloat
Definition: kaldi-types.h:29
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
void PushSpecial(VectorFst< StdArc > *fst, float delta)
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)