26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
30 typedef kaldi::int64 int64;
31 using fst::SymbolTable;
36 "Project lattices (in their transducer form); by default makes them\n" 37 "word->word transducers (set --project-output=false for tid->tid).\n" 38 "Usage: lattice-project [options] lattice-rspecifier lattice-wspecifier\n" 39 " e.g.: lattice-project ark:1.lats ark:word2word.lats\n" 40 "or: lattice-project --project-output=false ark:1.lats ark:tid2tid.lats";
43 bool project_output =
true;
45 po.
Register(
"project-output", &project_output,
"If true, project on output " 46 "(words), else input (transition-ids)");
55 std::string lats_rspecifier = po.
GetArg(1),
56 lats_wspecifier = po.
GetArg(2);
63 for (; !clat_reader.
Done(); clat_reader.
Next()) {
65 std::string key = clat_reader.
Key();
70 fst::Project(&lat, fst::PROJECT_OUTPUT);
71 lattice_writer.
Write(key, lat);
77 for (; !lattice_reader.
Done(); lattice_reader.
Next()) {
78 std::string key = lattice_reader.
Key();
81 fst::Project(&lat, fst::PROJECT_INPUT);
82 lattice_writer.
Write(key, lat);
86 KALDI_LOG <<
"Done projecting " << n_done <<
" lattices.";
87 return (n_done != 0 ? 0 : 1);
88 }
catch(
const std::exception &e) {
89 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void RemoveAlignmentsFromCompactLattice(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *fst)
Removes state-level alignments (the strings that are part of the weights).
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
int main(int argc, char *argv[])
void ConvertLattice(const ExpandedFst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *ofst, bool invert)
Convert lattice from a normal FST to a CompactLattice FST.
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< LatticeArc > Lattice
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
fst::VectorFst< CompactLatticeArc > CompactLattice
int NumArgs() const
Number of positional parameters (c.f. argc-1).