39 using namespace kaldi;
41 using fst::SymbolTable;
46 "Generate lattices using GMM-based model and RegTree-FMLLR adaptation.\n" 47 "Usage: gmm-latgen-faster-regtree-fmllr [options] model-in regtree-in (fst-in|fsts-rspecifier) features-rspecifier transform-rspecifier" 48 " lattice-wspecifier [ words-wspecifier [alignments-wspecifier] ]\n";
51 bool allow_partial =
false;
55 std::string word_syms_filename, utt2spk_rspecifier;
57 po.Register(
"utt2spk", &utt2spk_rspecifier,
"rspecifier for utterance to " 58 "speaker map used to load the transform");
59 po.Register(
"acoustic-scale", &acoustic_scale,
60 "Scaling factor for acoustic likelihoods");
61 po.Register(
"word-symbol-table", &word_syms_filename,
62 "Symbol table for words [for debug output]");
63 po.Register(
"allow-partial", &allow_partial,
64 "If true, produce output even if end state was not reached.");
68 if (po.NumArgs() < 4 || po.NumArgs() > 6) {
73 std::string model_in_filename = po.GetArg(1),
74 regtree_in_str = po.GetArg(2),
75 fst_in_str = po.GetArg(3),
76 feature_rspecifier = po.GetArg(4),
77 xforms_rspecifier = po.GetArg(5),
78 lattice_wspecifier = po.GetArg(6),
79 words_wspecifier = po.GetOptArg(7),
80 alignment_wspecifier = po.GetOptArg(8);
86 Input ki(model_in_filename, &binary);
87 trans_model.
Read(ki.Stream(), binary);
88 am_gmm.
Read(ki.Stream(), binary);
94 Input in(regtree_in_str, &binary_read);
95 regtree.
Read(in.Stream(), binary_read, am_gmm);
104 if (! (determinize ? compact_lattice_writer.
Open(lattice_wspecifier)
105 : lattice_writer.
Open(lattice_wspecifier)))
106 KALDI_ERR <<
"Could not open table for writing lattices: " 107 << lattice_wspecifier;
113 fst::SymbolTable *word_syms = NULL;
114 if (word_syms_filename !=
"")
115 if (!(word_syms = fst::SymbolTable::ReadText(word_syms_filename)))
116 KALDI_ERR <<
"Could not read symbol table from file " 117 << word_syms_filename;
119 double tot_like = 0.0;
120 kaldi::int64 frame_count = 0;
121 int num_done = 0, num_err = 0;
131 for (; !feature_reader.Done(); feature_reader.Next()) {
132 std::string utt = feature_reader.Key();
134 feature_reader.FreeCurrent();
135 if (features.NumRows() == 0) {
136 KALDI_WARN <<
"Zero-length utterance: " << utt;
140 if (!fmllr_reader.HasKey(utt)) {
141 KALDI_WARN <<
"Not decoding utterance " << utt
142 <<
" because no transform available.";
155 decoder, gmm_decodable, trans_model, word_syms, utt, acoustic_scale,
156 determinize, allow_partial, &alignment_writer, &words_writer,
157 &compact_lattice_writer, &lattice_writer, &like)) {
159 frame_count += features.NumRows();
168 for (; !fst_reader.Done(); fst_reader.Next()) {
169 std::string utt = fst_reader.Key();
172 KALDI_WARN <<
"Zero-length utterance: " << utt;
176 if (!fmllr_reader.HasKey(utt)) {
177 KALDI_WARN <<
"Not decoding utterance " << utt
178 <<
" because no transform available.";
192 decoder, gmm_decodable, trans_model, word_syms, utt, acoustic_scale,
193 determinize, allow_partial, &alignment_writer, &words_writer,
194 &compact_lattice_writer, &lattice_writer, &like)) {
196 frame_count += features.
NumRows();
202 double elapsed = timer.
Elapsed();
204 <<
"s: real-time factor assuming 100 frames/sec is " 205 << (elapsed*100.0/frame_count);
206 KALDI_LOG <<
"Done " << num_done <<
" utterances, failed for " 208 KALDI_LOG <<
"Overall log-likelihood per frame is " << (tot_like/frame_count) <<
" over " 209 << frame_count <<
" frames.";
212 if (num_done != 0)
return 0;
214 }
catch(
const std::exception &e) {
215 std::cerr << e.what();
void Read(std::istream &in, bool binary, const AmDiagGmm &am)
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
bool Open(const std::string &wspecifier)
Fst< StdArc > * ReadFstKaldiGeneric(std::string rxfilename, bool throw_on_err)
This class is for when you are reading something in random access, but it may actually be stored per-...
A templated class for writing objects to an archive or script file; see The Table concept...
bool DecodeUtteranceLatticeFaster(LatticeFasterDecoderTpl< FST > &decoder, DecodableInterface &decodable, const TransitionModel &trans_model, const fst::SymbolTable *word_syms, std::string utt, double acoustic_scale, bool determinize, bool allow_partial, Int32VectorWriter *alignment_writer, Int32VectorWriter *words_writer, CompactLatticeWriter *compact_lattice_writer, LatticeWriter *lattice_writer, double *like_ptr)
This function DecodeUtteranceLatticeFaster is used in several decoders, and we have moved it here...
RspecifierType ClassifyRspecifier(const std::string &rspecifier, std::string *rxfilename, RspecifierOptions *opts)
Allows random access to a collection of objects in an archive or script file; see The Table concept...
An FMLLR (feature-space MLLR) transformation, also called CMLLR (constrained MLLR) is an affine trans...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A regression tree is a clustering of Gaussian densities in an acoustic model, such that the group of ...
void Read(std::istream &is, bool binary)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
This is the "normal" lattice-generating decoder.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void Register(OptionsItf *opts)
double Elapsed() const
Returns time in seconds.
void Read(std::istream &in_stream, bool binary)