31 int main(
int argc,
char *argv[]) {
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.");
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);
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";
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...
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...
bool RescoreCompactLattice(DecodableInterface *decodable, CompactLattice *clat)
This function *adds* the negated scores obtained from the Decodable object, to the acoustic scores on...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
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...
const T & Value(const std::string &key)
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...
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.
int main(int argc, char *argv[])
bool HasKey(const std::string &key)
fst::VectorFst< CompactLatticeArc > CompactLattice
int NumArgs() const
Number of positional parameters (c.f. argc-1).
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Read(std::istream &in_stream, bool binary)