All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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

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::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  if (po.NumArgs() > 1) {
49  po.PrintUsage();
50  exit(1);
51  }
52 
53  std::string fst_out_filename = po.GetOptArg(1);
54 
55  VectorFst <StdArc> *rand_fst = RandFst<StdArc>(opts);
56 
57  WriteFstKaldi(*rand_fst, fst_out_filename);
58  delete rand_fst;
59  return 0;
60  } catch(const std::exception &e) {
61  std::cerr << e.what();
62  return -1;
63  }
64 }
Definition: graph.dox:21
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)