53 KALDI_WARN <<
"For key " <<
key_ <<
", determinization did not succeed" 54 "(partial output will be pruned tighter than the specified beam.)";
68 <<
" for key " <<
key_;
89 int main(
int argc,
char *argv[]) {
91 using namespace kaldi;
95 "Determinize lattices, keeping only the best path (sequence of\n" 96 "acoustic states) for each input-symbol sequence. This is a version\n" 97 "of lattice-determinize-phone-pruned that accepts the --num-threads\n" 98 "option. The program does phone insertion when doing a first pass\n" 99 "determinization, it then removes the inserted symbols and does a\n" 100 "second pass determinization. It also does pruning as part of the\n" 101 "determinization algorithm, which is more efficient and prevents\n" 104 "Usage: lattice-determinize-phone-pruned-parallel [options] \\\n" 105 " <model> <lattice-rspecifier> <lattice-wspecifier>\n" 106 " e.g.: lattice-determinize-phone-pruned-parallel \\\n" 107 " --acoustic-scale=0.1 final.mdl ark:in.lats ark:det.lats\n";
115 determinize_opts.
max_mem = 50000000;
117 po.
Register(
"acoustic-scale", &acoustic_scale,
"Scaling factor for acoustic" 119 po.
Register(
"beam", &beam,
"Pruning beam [applied after acoustic scaling].");
129 std::string model_rxfilename = po.
GetArg(1),
130 lats_rspecifier = po.
GetArg(2),
131 lats_wspecifier = po.
GetArg(3);
145 int32 n_done = 0, n_warn = 0;
147 if (acoustic_scale == 0.0)
148 KALDI_ERR <<
"Do not use a zero acoustic scale (cannot be inverted)";
150 for (; !lat_reader.
Done(); lat_reader.
Next()) {
151 std::string key = lat_reader.
Key();
156 KALDI_VLOG(2) <<
"Processing lattice " << key;
159 trans_model, determinize_opts, key, acoustic_scale, beam,
160 lat, &compact_lat_writer, &n_warn);
166 KALDI_LOG <<
"Done " << n_done <<
" lattices, determinization finished " 167 <<
"earlier than specified by the beam on " << n_warn <<
" of " 169 return (n_done != 0 ? 0 : 1);
170 }
catch(
const std::exception &e) {
171 std::cerr << e.what();
int main(int argc, char *argv[])
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Register(kaldi::OptionsItf *opts)
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 ...
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...
~DeterminizeLatticeTask()
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
std::vector< std::vector< double > > AcousticLatticeScale(double acwt)
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...
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 TransitionModel * trans_model_
const fst::DeterminizeLatticePhonePrunedOptions & opts_
bool DeterminizeLatticePhonePrunedWrapper(const kaldi::TransitionModel &trans_model, MutableFst< kaldi::LatticeArc > *ifst, double beam, MutableFst< kaldi::CompactLatticeArc > *ofst, DeterminizeLatticePhonePrunedOptions opts)
This function is a wrapper of DeterminizeLatticePhonePruned() that works for Lattice type FSTs...
void Register(OptionsItf *opts)