26 using namespace kaldi;
28 typedef kaldi::int64 int64;
29 using fst::SymbolTable;
34 "Expand lattices so that each arc has a unique n-label history, for\n" 35 "a specified n (defaults to 3).\n" 36 "Usage: lattice-expand-ngram [options] lattice-rspecifier " 37 "lattice-wspecifier\n" 38 "e.g.: lattice-expand-ngram --n=3 ark:lat ark:expanded_lat\n";
43 std::string word_syms_filename;
44 po.Register(
"n", &n,
"n-gram context to expand to.");
48 if (po.NumArgs() != 2) {
55 std::string lats_rspecifier = po.GetArg(1),
56 lats_wspecifier = po.GetOptArg(2);
63 int32 n_done = 0, n_fail = 0;
65 for (; !lat_reader.Done(); lat_reader.Next()) {
66 std::string key = lat_reader.Key();
67 KALDI_LOG <<
"Processing lattice for key " << key;
71 if (expanded_lat.Start() == fst::kNoStateId) {
72 KALDI_WARN <<
"Empty lattice for utterance " << key;
75 if (lat.NumStates() == expanded_lat.NumStates()) {
77 <<
" did not need to be expanded for order " << n <<
".";
79 KALDI_LOG <<
"Lattice expanded from " << lat.NumStates() <<
" to " 80 << expanded_lat.NumStates() <<
" states for order " << n <<
".";
82 lat_writer.Write(key, expanded_lat);
85 lat_reader.FreeCurrent();
87 KALDI_LOG <<
"Processed " << n_done <<
" lattices with " << n_fail
90 }
catch(
const std::exception &e) {
91 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ComposeDeterministicOnDemand(const Fst< Arc > &fst1, DeterministicOnDemandFst< Arc > *fst2, MutableFst< Arc > *fst_composed)
A templated class for writing objects to an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< CompactLatticeArc > CompactLattice
The class UnweightedNgramFst is a DeterministicOnDemandFst whose states encode an n-gram history...
#define KALDI_ASSERT(cond)
fst::ArcTpl< CompactLatticeWeight > CompactLatticeArc