lattice-rmali.cc File Reference
Include dependency graph for lattice-rmali.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 26 of file lattice-rmali.cc.

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

26  {
27  try {
28  using namespace kaldi;
29  typedef kaldi::int32 int32;
30  typedef kaldi::int64 int64;
31  using fst::SymbolTable;
32  using fst::VectorFst;
33  using fst::StdArc;
34 
35  const char *usage =
36  "Remove state-sequences from lattice weights\n"
37  "Usage: lattice-rmali [options] lattice-rspecifier lattice-wspecifier\n"
38  " e.g.: lattice-rmali ark:1.lats ark:proj.lats\n";
39 
40  ParseOptions po(usage);
41 
42  po.Read(argc, argv);
43 
44  if (po.NumArgs() != 2) {
45  po.PrintUsage();
46  exit(1);
47  }
48 
49  std::string lats_rspecifier = po.GetArg(1),
50  lats_wspecifier = po.GetArg(2);
51 
52  SequentialCompactLatticeReader lattice_reader(lats_rspecifier);
53 
54  // Write as compact lattice.
55  CompactLatticeWriter compact_lattice_writer(lats_wspecifier);
56 
57  int32 n_done = 0; // there is no failure mode, barring a crash.
58 
59  for (; !lattice_reader.Done(); lattice_reader.Next()) {
60  std::string key = lattice_reader.Key();
61  CompactLattice clat = lattice_reader.Value();
62  lattice_reader.FreeCurrent();
64  compact_lattice_writer.Write(key, clat);
65  n_done++;
66  }
67  KALDI_LOG << "Done removing alignments from " << n_done << " lattices.";
68  return (n_done != 0 ? 0 : 1);
69  } catch(const std::exception &e) {
70  std::cerr << e.what();
71  return -1;
72  }
73 }
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
void RemoveAlignmentsFromCompactLattice(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *fst)
Removes state-level alignments (the strings that are part of the weights).
fst::StdArc StdArc
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
fst::VectorFst< CompactLatticeArc > CompactLattice
Definition: kaldi-lattice.h:46
#define KALDI_LOG
Definition: kaldi-error.h:153