33 using namespace kaldi;
35 typedef kaldi::int64 int64;
36 using fst::SymbolTable;
41 "Replace the acoustic scores on a lattice using a new model.\n" 42 "Usage: gmm-rescore-lattice [options] <model-in> <lattice-rspecifier> " 43 "<feature-rspecifier> <lattice-wspecifier>\n" 44 " e.g.: gmm-rescore-lattice 1.mdl ark:1.lats scp:trn.scp ark:2.lats\n";
48 po.Register(
"old-acoustic-scale", &old_acoustic_scale,
49 "Add in the scores in the input lattices with this scale, rather " 50 "than discarding them.");
53 if (po.NumArgs() != 4) {
58 std::string model_filename = po.GetArg(1),
59 lats_rspecifier = po.GetArg(2),
60 feature_rspecifier = po.GetArg(3),
61 lats_wspecifier = po.GetArg(4);
67 Input ki(model_filename, &binary);
68 trans_model.
Read(ki.Stream(), binary);
69 am_gmm.
Read(ki.Stream(), binary);
78 int32 num_done = 0, num_err = 0;
80 for (; !compact_lattice_reader.Done(); compact_lattice_reader.Next()) {
81 std::string key = compact_lattice_reader.Key();
82 if (!feature_reader.HasKey(key)) {
83 KALDI_WARN <<
"No feature found for utterance " << key <<
". Skipping";
89 compact_lattice_reader.FreeCurrent();
90 if (old_acoustic_scale != 1.0)
97 compact_lattice_writer.Write(key, clat);
103 KALDI_LOG <<
"Done " << num_done <<
" lattices with errors on " 104 << num_err <<
", #frames is " << num_frames;
105 return (num_done != 0 ? 0 : 1);
106 }
catch(
const std::exception &e) {
107 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...
bool RescoreCompactLattice(DecodableInterface *decodable, CompactLattice *clat)
This function *adds* the negated scores obtained from the Decodable object, to the acoustic scores on...
Allows random access to a collection of objects in an archive or script file; see The Table concept...
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...
void Read(std::istream &is, bool binary)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< CompactLatticeArc > CompactLattice
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Read(std::istream &in_stream, bool binary)