26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
30 typedef kaldi::int64 int64;
31 using fst::SymbolTable;
40 "Turn lattices into normal FSTs, retaining only the word labels\n" 41 "By default, removes all weights and also epsilons (configure with\n" 42 "with --acoustic-scale, --lm-scale and --rm-eps)\n" 43 "Usage: lattice-to-fst [options] lattice-rspecifier fsts-wspecifier\n" 44 " e.g.: lattice-to-fst ark:1.lats ark:1.fsts\n";
47 po.
Register(
"acoustic-scale", &acoustic_scale,
"Scaling factor for acoustic likelihoods");
48 po.
Register(
"lm-scale", &lm_scale,
"Scaling factor for graph/lm costs");
49 po.
Register(
"rm-eps", &rm_eps,
"Remove epsilons in resulting FSTs (in lazy way; may not remove all)");
60 std::string lats_rspecifier = po.
GetArg(1),
61 fsts_wspecifier = po.
GetArg(2);
68 for (; !lattice_reader.
Done(); lattice_reader.
Next()) {
69 std::string key = lattice_reader.
Key();
74 fst::VectorFst<StdArc>
fst;
81 Project(&fst, fst::PROJECT_OUTPUT);
86 fst_writer.
Write(key, fst);
89 KALDI_LOG <<
"Done converting " << n_done <<
" lattices to word-level FSTs";
90 return (n_done != 0 ? 0 : 1);
91 }
catch(
const std::exception &e) {
92 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 RemoveEpsLocal(MutableFst< Arc > *fst)
RemoveEpsLocal remove some (but not necessarily all) epsilons in an FST, using an algorithm that is g...
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
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...
void ScaleLattice(const std::vector< std::vector< ScaleFloat > > &scale, MutableFst< ArcTpl< Weight > > *fst)
Scales the pairs of weights in LatticeWeight or CompactLatticeWeight by viewing the pair (a...
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...
std::vector< std::vector< double > > LatticeScale(double lmwt, double acwt)
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).
int main(int argc, char *argv[])