40 using namespace kaldi;
43 using fst::SymbolTable;
47 const char *usage =
"Decode features using GMM-based model. Note: the input\n" 48 "<gmms-rspecifier> will typically be piped in from gmm-est-map.\n" 49 "Note: <model-in> is only needed for the transition-model, which isn't\n" 50 "included in <gmms-rspecifier>.\n" 52 "Usage: gmm-latgen-map [options] <model-in> " 53 "<gmms-rspecifier> <fsts-rxfilename|fsts-rspecifier> <features-rspecifier> " 54 "<lattice-wspecifier> [ <words-wspecifier> [ <alignments-wspecifier> ] ]\n";
58 bool allow_partial =
true;
61 std::string word_syms_filename, utt2spk_rspecifier;
64 po.Register(
"utt2spk", &utt2spk_rspecifier,
"rspecifier for utterance to " 66 po.Register(
"binary", &binary,
"Write output in binary mode");
67 po.Register(
"acoustic-scale", &acoustic_scale,
68 "Scaling factor for acoustic likelihoods");
69 po.Register(
"word-symbol-table", &word_syms_filename,
70 "Symbol table for words [for debug output]");
71 po.Register(
"allow-partial", &allow_partial,
72 "Produce output even when final state was not reached");
75 if (po.NumArgs() < 5 || po.NumArgs() > 7) {
80 std::string model_in_filename = po.GetArg(1),
81 gmms_rspecifier = po.GetArg(2),
82 fst_in_filename = po.GetArg(3),
83 feature_rspecifier = po.GetArg(4),
84 lattice_wspecifier = po.GetArg(5),
85 words_wspecifier = po.GetOptArg(6),
86 alignment_wspecifier = po.GetOptArg(7);
91 Input is(model_in_filename, &binary_read);
92 trans_model.
Read(is.Stream(), binary_read);
103 KALDI_WARN <<
"determinize is set to FASLE ...";
107 if (lattice_wspecifier !=
"") {
108 if (! (determinize ? compact_lattice_writer.
Open(lattice_wspecifier)
109 : lattice_writer.
Open(lattice_wspecifier)))
110 KALDI_ERR <<
"Could not open table for writing lattices: " 111 << lattice_wspecifier;
114 fst::SymbolTable *word_syms = NULL;
115 if (word_syms_filename !=
"") {
116 word_syms = fst::SymbolTable::ReadText(word_syms_filename);
118 KALDI_ERR <<
"Could not read symbol table from file " 119 << word_syms_filename;
124 kaldi::int64 frame_count = 0;
125 int num_success = 0, num_fail = 0;
133 for (; !feature_reader.Done(); feature_reader.Next()) {
134 string utt = feature_reader.Key();
136 if (!gmms_reader.HasKey(utt)) {
138 <<
" has no corresponding MAP model skipping this utterance.";
146 feature_reader.FreeCurrent();
147 if (features.NumRows() == 0) {
148 KALDI_WARN <<
"Zero-length utterance: " << utt;
159 decoder, gmm_decodable, trans_model, word_syms, utt,
160 acoustic_scale, determinize, allow_partial, &alignment_writer,
161 &words_writer, &compact_lattice_writer, &lattice_writer,
164 frame_count += features.NumRows();
171 for (; !feature_reader.Done(); feature_reader.Next()) {
172 string utt = feature_reader.Key();
174 if (!fst_reader.HasKey(utt)) {
175 KALDI_WARN <<
"Utterance " << utt <<
" has no corresponding FST" 176 <<
"skipping this utterance.";
181 if (!gmms_reader.HasKey(utt)) {
183 <<
" has no corresponding MAP model skipping this utterance.";
191 feature_reader.FreeCurrent();
192 if (features.NumRows() == 0) {
193 KALDI_WARN <<
"Zero-length utterance: " << utt;
204 decoder, gmm_decodable, trans_model, word_syms, utt,
205 acoustic_scale, determinize, allow_partial, &alignment_writer,
206 &words_writer, &compact_lattice_writer, &lattice_writer,
209 frame_count += features.NumRows();
214 KALDI_LOG <<
"Average log-likelihood per frame is " 215 << (tot_like / frame_count) <<
" over " << frame_count <<
" frames.";
217 double elapsed = timer.
Elapsed();
218 KALDI_LOG <<
"Time taken [excluding initialization] " << elapsed
219 <<
"s: real-time factor assuming 100 frames/sec is " 220 << (elapsed * 100.0 / frame_count);
221 KALDI_LOG <<
"Done " << num_success <<
" utterances, failed for " 225 return (num_success != 0 ? 0 : 1);
227 catch(
const std::exception& e) {
228 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void CopyFromAmDiagGmm(const AmDiagGmm &other)
Copies the parameters from another model. Allocates necessary memory.
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...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
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.
void Register(OptionsItf *opts)
double Elapsed() const
Returns time in seconds.