30 class DeterminizeLatticeTask {
52 KALDI_WARN <<
"Could not topologically sort lattice: this probably means it" 53 " has bad properties e.g. epsilon cycles. Your LM or lexicon might " 54 "be broken, e.g. LM with epsilon cycles or lexicon with empty words.";
57 fst::ArcSort(
lat_, fst::ILabelCompare<LatticeArc>());
59 KALDI_WARN <<
"For key " <<
key_ <<
", determinization did not succeed" 60 "(partial output will be pruned tighter than the specified beam.)";
77 <<
" for key " <<
key_;
97 int main(
int argc,
char *argv[]) {
99 using namespace kaldi;
103 "Determinize lattices, keeping only the best path (sequence of acoustic states)\n" 104 "for each input-symbol sequence. This is a version of lattice-determnize-pruned\n" 105 "that accepts the --num-threads option. These programs do pruning as part of the\n" 106 "determinization algorithm, which is more efficient and prevents blowup.\n" 107 "See http://kaldi-asr.org/doc/lattices.html for more information on lattices.\n" 109 "Usage: lattice-determinize-pruned-parallel [options] lattice-rspecifier lattice-wspecifier\n" 110 " e.g.: lattice-determinize-pruned-parallel --acoustic-scale=0.1 --beam=6.0 ark:in.lats ark:det.lats\n";
115 bool minimize =
false;
120 determinize_config.
max_mem = 50000000;
123 po.
Register(
"acoustic-scale", &acoustic_scale,
124 "Scaling factor for acoustic likelihoods");
125 po.
Register(
"beam", &beam,
"Pruning beam [applied after acoustic scaling].");
127 "If true, push and minimize after determinization");
137 std::string lats_rspecifier = po.
GetArg(1),
138 lats_wspecifier = po.
GetArg(2);
149 int32 n_done = 0, n_warn = 0;
151 if (acoustic_scale == 0.0)
152 KALDI_ERR <<
"Do not use a zero acoustic scale (cannot be inverted)";
154 for (; !lat_reader.
Done(); lat_reader.
Next()) {
155 std::string key = lat_reader.
Key();
160 KALDI_VLOG(2) <<
"Processing lattice " << key;
163 determinize_config, key, acoustic_scale, beam, minimize,
164 lat, &compact_lat_writer, &n_warn);
169 KALDI_LOG <<
"Done " << n_done <<
" lattices, had warnings on " << n_warn
171 return (n_done != 0 ? 0 : 1);
172 }
catch(
const std::exception &e) {
173 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
BaseFloat acoustic_scale_
void Run(C *c)
This function takes ownership of the pointer "c", and will delete it in the same sequence as Run was ...
bool DeterminizeLatticePruned(const ExpandedFst< ArcTpl< Weight > > &ifst, double beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePrunedOptions opts)
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
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...
~DeterminizeLatticeTask()
DeterminizeLatticeTask(fst::DeterminizeLatticePrunedOptions &opts, std::string key, BaseFloat acoustic_scale, BaseFloat beam, bool minimize, Lattice *lat, CompactLatticeWriter *clat_writer, int32 *num_warn)
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
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...
const fst::DeterminizeLatticePrunedOptions & opts_
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.
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 Register(kaldi::OptionsItf *opts)
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.
DeterminizeLatticeTask(const TransitionModel &trans_model, fst::DeterminizeLatticePhonePrunedOptions &opts, std::string key, BaseFloat acoustic_scale, BaseFloat beam, Lattice *lat, CompactLatticeWriter *clat_writer, int32 *num_warn)
fst::VectorFst< CompactLatticeArc > CompactLattice
int NumArgs() const
Number of positional parameters (c.f. argc-1).
CompactLatticeWriter * clat_writer_
const fst::DeterminizeLatticePhonePrunedOptions & opts_
int main(int argc, char *argv[])
void Register(OptionsItf *opts)