91 using namespace kaldi;
93 typedef kaldi::int64 int64;
94 using fst::SymbolTable;
99 "This program is deprecated, please used lattice-determinize-pruned.\n" 100 "lattice-determinize lattices (and apply a pruning beam)\n" 101 " (see http://kaldi-asr.org/doc/lattices.html for more explanation)\n" 102 " note: this program is tyically only useful if you generated state-level\n" 103 " lattices, e.g. called gmm-latgen-simple with --determinize=false\n" 105 "Usage: lattice-determinize [options] lattice-rspecifier lattice-wspecifier\n" 106 " e.g.: lattice-determinize --acoustic-scale=0.1 --beam=15.0 ark:1.lats ark:det.lats\n";
112 int32 num_loops = 20;
113 int32 max_mem = 50000000;
114 int32 max_loop = 500000;
117 bool minimize =
false;
119 po.Register(
"acoustic-scale", &acoustic_scale,
120 "Scaling factor for acoustic likelihoods");
121 po.Register(
"beam", &beam,
122 "Pruning beam [applied after acoustic scaling]-- also used " 123 "to handle determinization failures, set --prune=false to " 124 "disable routine pruning");
125 po.Register(
"delta", &delta,
"Tolerance used in determinization");
126 po.Register(
"prune", &prune,
"If true, prune determinized lattices " 127 "with the --beam option.");
128 po.Register(
"max-mem", &max_mem,
"Maximum approximate memory usage in " 129 "determinization (real usage might be many times this)");
130 po.Register(
"max-loop", &max_loop,
"Option to detect a certain " 131 "type of failure in lattice determinization (not critical)");
132 po.Register(
"beam-ratio", &beam_ratio,
"Ratio by which to " 133 "decrease beam if we reach the max-arcs.");
134 po.Register(
"num-loops", &num_loops,
"Number of times to " 135 "decrease beam by beam-ratio if determinization fails.");
136 po.Register(
"minimize", &minimize,
137 "If true, push and minimize after determinization");
141 if (po.NumArgs() != 2) {
146 std::string lats_rspecifier = po.GetArg(1),
147 lats_wspecifier = po.GetArg(2);
157 int32 n_done = 0, n_error = 0;
160 double sum_depth_in = 0.0,
161 sum_depth_out = 0.0, sum_t = 0.0;
163 if (acoustic_scale == 0.0)
164 KALDI_ERR <<
"Do not use a zero acoustic scale (cannot be inverted)";
165 LatticeWeight beam_weight(beam, static_cast<BaseFloat>(0.0));
167 for (; !lattice_reader.Done(); lattice_reader.Next()) {
168 std::string key = lattice_reader.Key();
169 Lattice lat = lattice_reader.Value();
172 lattice_reader.FreeCurrent();
177 beam, beam_ratio, max_mem, max_loop,
178 delta, num_loops, &clat)) {
188 sum_depth_in += lat.NumStates();
189 sum_depth_out += depth * t;
193 compact_lattice_writer.Write(key, clat);
201 KALDI_LOG <<
"Average input-lattice depth (measured at at state level) is " 202 << (sum_depth_in / sum_t) <<
", output depth is " 203 << (sum_depth_out / sum_t) <<
", over " << sum_t <<
" frames " 204 <<
" (average num-frames = " << (sum_t / n_done) <<
").";
206 KALDI_LOG <<
"Done " << n_done <<
" lattices, errors on " << n_error;
207 return (n_done != 0 ? 0 : 1);
208 }
catch(
const std::exception &e) {
209 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool DeterminizeLatticeWrapper(const Lattice &lat, const std::string &key, bool prune, BaseFloat beam, BaseFloat beam_ratio, int32 max_mem, int32 max_loop, BaseFloat delta, int32 num_loops, CompactLattice *clat)
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...
std::vector< std::vector< double > > AcousticLatticeScale(double acwt)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
bool MinimizeCompactLattice(MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *clat, float delta)
This function minimizes the compact lattice.
BaseFloat CompactLatticeDepth(const CompactLattice &clat, int32 *num_frames)
Returns the depth of the lattice, defined as the average number of arcs crossing any given frame...
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...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< LatticeArc > Lattice
fst::VectorFst< CompactLatticeArc > CompactLattice
void TopSortCompactLatticeIfNeeded(CompactLattice *clat)
Topologically sort the compact lattice if not already topologically sorted.