fstdeterminizestart.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 fstdeterminizestart.cc:

Go to the source code of this file.

Namespaces

 fst
 For an extended explanation of the framework of which grammar-fsts are a part, please see Support for grammars and graphs with on-the-fly parts. (i.e.
 

Functions

static void InputDeterminizeSingleState (StdArc::StateId s, VectorFst< StdArc > *fst)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

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

Definition at line 116 of file fstdeterminizestart.cc.

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

116  {
117  try {
118  using namespace kaldi;
119  using namespace fst;
120  using kaldi::int32;
121 
122  const char *usage =
123  "Removes some (but not all) epsilons in an algorithm that will always reduce the number of\n"
124  "arcs+states. Option to preserves equivalence in tropical or log semiring, and\n"
125  "if in tropical, stochasticit in either log or tropical.\n"
126  "\n"
127  "Usage: fstrmepslocal [in.fst [out.fst] ]\n";
128 
129  ParseOptions po(usage);
130  bool use_log = false;
131  bool stochastic_in_log = true;
132  po.Register("use-log", &use_log,
133  "Preserve equivalence in log semiring [false->tropical]\n");
134  po.Register("stochastic-in-log", &stochastic_in_log,
135  "Preserve stochasticity in log semiring [false->tropical]\n");
136  po.Read(argc, argv);
137 
138  if (po.NumArgs() > 2) {
139  po.PrintUsage();
140  exit(1);
141  }
142 
143  std::string fst_in_filename = po.GetOptArg(1),
144  fst_out_filename = po.GetOptArg(2);
145 
146  VectorFst<StdArc> *fst = ReadFstKaldi(fst_in_filename);
147 
148  fst::InputDeterminizeSingleState(fst->Start(), fst);
149  WriteFstKaldi(*fst, fst_out_filename);
150  delete fst;
151  return 0;
152  } catch(const std::exception &e) {
153  std::cerr << e.what();
154  return -1;
155  }
156 }
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
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
static void InputDeterminizeSingleState(StdArc::StateId s, VectorFst< StdArc > *fst)
This utility function input-determinizes a specified state s of the FST &#39;fst&#39;.
Definition: grammar-fst.cc:472
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)