fstrand.cc File Reference
#include "base/kaldi-common.h"
#include "util/kaldi-io.h"
#include "util/parse-options.h"
#include "util/text-utils.h"
#include "fstext/rand-fst.h"
#include "time.h"
#include "fstext/fstext-utils.h"
#include "fstext/kaldi-fst-io.h"
Include dependency graph for fstrand.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 fstrand.cc.

References RandFstOptions::allow_empty, ParseOptions::GetOptArg(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), ParseOptions::Register(), and fst::WriteFstKaldi().

30  {
31  try {
32  using namespace fst;
33  using kaldi::int32;
34 
35  const char *usage =
36  "Generate random FST\n"
37  "\n"
38  "Usage: fstrand [out.fst]\n";
39 
40  srand(time(NULL));
41  RandFstOptions opts;
42 
43 
44  kaldi::ParseOptions po(usage);
45  po.Register("allow-empty", &opts.allow_empty,
46  "If true, we may generate an empty FST.");
47 
48  po.Read(argc, argv);
49 
50  if (po.NumArgs() > 1) {
51  po.PrintUsage();
52  exit(1);
53  }
54 
55  std::string fst_out_filename = po.GetOptArg(1);
56 
57  VectorFst <StdArc> *rand_fst = RandFst<StdArc>(opts);
58 
59  WriteFstKaldi(*rand_fst, fst_out_filename);
60  delete rand_fst;
61  return 0;
62  } catch(const std::exception &e) {
63  std::cerr << e.what();
64  return -1;
65  }
66 }
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
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)