31 using namespace kaldi;
33 typedef kaldi::int64 int64;
34 using fst::SymbolTable;
39 "Push lattices, in CompactLattice format, so that the strings are as\n" 40 "close to the start as possible, and the lowest cost weight for each\n" 41 "state except the start state is (0, 0). This can be helpful prior to\n" 42 "word-alignment (in this case, only strings need to be pushed)\n" 44 "Usage: lattice-push [options] lattice-rspecifier lattice-wspecifier\n" 45 " e.g.: lattice-push ark:1.lats ark:2.lats\n";
49 bool push_strings =
true;
50 bool push_weights =
true;
52 po.Register(
"push-strings", &push_strings,
"If true, push the strings in the " 53 "lattice to the start.");
54 po.Register(
"push-weights", &push_weights,
"If true, push the weights in the " 55 "lattice to the start.");
59 if (po.NumArgs() != 2) {
64 std::string lats_rspecifier = po.GetArg(1),
65 lats_wspecifier = po.GetArg(2);
71 int32 n_done = 0, n_err = 0;
74 for (; !clat_reader.Done(); clat_reader.Next()) {
75 std::string key = clat_reader.Key();
77 KALDI_VLOG(1) <<
"Processing lattice for utterance " << key;
79 KALDI_WARN <<
"Failure in pushing lattice strings (bad lattice?), " 85 KALDI_WARN <<
"Failure in pushing lattice weights (bad lattice?)," 86 <<
"for key " << key ;
90 if (clat.NumStates() == 0) {
95 clat_writer.Write(key, clat);
98 KALDI_LOG <<
"Pushed " << n_done <<
" lattices, errors on " << n_err;
99 return (n_done != 0 ? 0 : 1);
100 }
catch(
const std::exception &e) {
101 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool PushCompactLatticeStrings(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *clat)
This function pushes the transition-ids as far towards the start as they will go. ...
A templated class for writing objects to an archive or script file; see The Table concept...
bool PushCompactLatticeWeights(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *clat)
This function pushes the weights in the CompactLattice so that all states except possibly the start s...
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