fstcopy.cc File Reference
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "fst/fstlib.h"
#include "fstext/table-matcher.h"
#include "fstext/fstext-utils.h"
#include "fstext/kaldi-fst-io.h"
Include dependency graph for fstcopy.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 41 of file fstcopy.cc.

References SequentialTableReader< Holder >::Done(), ParseOptions::GetArg(), KALDI_LOG, SequentialTableReader< Holder >::Key(), SequentialTableReader< Holder >::Next(), ParseOptions::NumArgs(), ParseOptions::PrintUsage(), ParseOptions::Read(), SequentialTableReader< Holder >::Value(), and TableWriter< Holder >::Write().

41  {
42  try {
43  using namespace kaldi;
44  using namespace fst;
45  using kaldi::int32;
46 
47  const char *usage =
48  "Copy tables/archives of FSTs, indexed by a string (e.g. utterance-id)\n"
49  "\n"
50  "Usage: fstcopy <fst-rspecifier> <fst-wspecifier>\n";
51 
52  ParseOptions po(usage);
53 
54  po.Read(argc, argv);
55 
56  if (po.NumArgs() != 2) {
57  po.PrintUsage();
58  exit(1);
59  }
60 
61  std::string fst_rspecifier = po.GetArg(1),
62  fst_wspecifier = po.GetArg(2);
63 
64  SequentialTableReader<VectorFstHolder> fst_reader(fst_rspecifier);
65  TableWriter<VectorFstHolder> fst_writer(fst_wspecifier);
66  int32 n_done = 0;
67 
68  for (; !fst_reader.Done(); fst_reader.Next(), n_done++)
69  fst_writer.Write(fst_reader.Key(), fst_reader.Value());
70 
71  KALDI_LOG << "Copied " << n_done << " FSTs.";
72  return (n_done != 0 ? 0 : 1);
73  } catch(const std::exception &e) {
74  std::cerr << e.what();
75  return -1;
76  }
77 }
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
A templated class for writing objects to an archive or script file; see The Table concept...
Definition: kaldi-table.h:368
kaldi::int32 int32
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Definition: parse-options.h:36
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
Definition: kaldi-table.h:287
#define KALDI_LOG
Definition: kaldi-error.h:153