29 using namespace kaldi;
31 typedef kaldi::int64 int64;
32 using fst::SymbolTable;
37 "Apply scaling to lattice weights\n" 38 "Usage: lattice-scale [options] lattice-rspecifier lattice-wspecifier\n" 39 " e.g.: lattice-scale --lm-scale=0.0 ark:1.lats ark:scaled.lats\n";
42 bool write_compact =
true;
49 po.Register(
"write-compact", &write_compact,
"If true, write in normal (compact) form.");
50 po.Register(
"acoustic-scale", &acoustic_scale,
"Scaling factor for acoustic likelihoods");
51 po.Register(
"inv-acoustic-scale", &inv_acoustic_scale,
"An alternative way " 52 "of setting the acoustic scale: you can set its inverse.");
53 po.Register(
"lm-scale", &lm_scale,
"Scaling factor for graph/lm costs");
54 po.Register(
"acoustic2lm-scale", &acoustic2lm_scale,
"Add this times original acoustic costs to LM costs");
55 po.Register(
"lm2acoustic-scale", &lm2acoustic_scale,
"Add this times original LM costs to acoustic costs");
59 if (po.NumArgs() != 2) {
64 std::string lats_rspecifier = po.GetArg(1),
65 lats_wspecifier = po.GetArg(2);
69 KALDI_ASSERT(acoustic_scale == 1.0 || inv_acoustic_scale == 1.0);
70 if (inv_acoustic_scale != 1.0)
71 acoustic_scale = 1.0 / inv_acoustic_scale;
73 std::vector<std::vector<double> > scale(2);
76 scale[0][0] = lm_scale;
77 scale[0][1] = acoustic2lm_scale;
78 scale[1][0] = lm2acoustic_scale;
79 scale[1][1] = acoustic_scale;
87 for (; !compact_lattice_reader.Done(); compact_lattice_reader.Next()) {
90 compact_lattice_writer.Write(compact_lattice_reader.Key(), lat);
99 for (; !lattice_reader.Done(); lattice_reader.Next()) {
100 Lattice lat = lattice_reader.Value();
102 lattice_writer.Write(lattice_reader.Key(), lat);
107 KALDI_LOG <<
"Done " << n_done <<
" lattices.";
108 return (n_done != 0 ? 0 : 1);
109 }
catch(
const std::exception &e) {
110 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
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...
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
#define KALDI_ASSERT(cond)