38 using namespace kaldi;
40 using fst::SymbolTable;
46 "Decode features using GMM-based model. Uses multiple decoding threads,\n" 47 "but interface and behavior is otherwise the same as gmm-latgen-faster\n" 48 "Usage: gmm-latgen-faster-parallel [options] model-in (fst-in|fsts-rspecifier) " 49 "features-rspecifier lattice-wspecifier [ words-wspecifier [alignments-wspecifier] ]\n";
52 bool allow_partial =
false;
58 std::string word_syms_filename;
61 po.Register(
"acoustic-scale", &acoustic_scale,
62 "Scaling factor for acoustic likelihoods");
63 po.Register(
"log-sum-exp-prune", &log_sum_exp_prune,
64 "If >0, pruning parameter to minimize exp()'s. Suggest 3 to 5; " 65 "larger is more exact.");
66 po.Register(
"word-symbol-table", &word_syms_filename,
67 "Symbol table for words [for debug output]");
68 po.Register(
"allow-partial", &allow_partial,
69 "If true, produce output even if end state was not reached.");
73 if (po.NumArgs() < 4 || po.NumArgs() > 6) {
78 std::string model_in_filename = po.GetArg(1),
79 fst_in_str = po.GetArg(2),
80 feature_rspecifier = po.GetArg(3),
81 lattice_wspecifier = po.GetArg(4),
82 words_wspecifier = po.GetOptArg(5),
83 alignment_wspecifier = po.GetOptArg(6);
89 Input ki(model_in_filename, &binary);
90 trans_model.
Read(ki.Stream(), binary);
91 am_gmm.
Read(ki.Stream(), binary);
97 if (! (determinize ? compact_lattice_writer.
Open(lattice_wspecifier)
98 : lattice_writer.
Open(lattice_wspecifier)))
99 KALDI_ERR <<
"Could not open table for writing lattices: " 100 << lattice_wspecifier;
106 fst::SymbolTable *word_syms = NULL;
107 if (word_syms_filename !=
"")
108 if (!(word_syms = fst::SymbolTable::ReadText(word_syms_filename)))
109 KALDI_ERR <<
"Could not read symbol table from file " 110 << word_syms_filename;
112 double tot_like = 0.0;
113 kaldi::int64 frame_count = 0;
114 int num_done = 0, num_err = 0;
115 Fst<StdArc> *decode_fst = NULL;
128 for (; !feature_reader.Done(); feature_reader.Next()) {
129 std::string utt = feature_reader.Key();
132 feature_reader.FreeCurrent();
133 if (features->
NumRows() == 0) {
134 KALDI_WARN <<
"Zero-length utterance: " << utt;
151 decoder, gmm_decodable,
152 trans_model, word_syms, utt, acoustic_scale, determinize,
153 allow_partial, &alignment_writer, &words_writer,
154 &compact_lattice_writer, &lattice_writer,
155 &tot_like, &frame_count, &num_done, &num_err, NULL);
164 for (; !fst_reader.Done(); fst_reader.Next()) {
165 std::string utt = fst_reader.Key();
166 if (!feature_reader.HasKey(utt)) {
167 KALDI_WARN <<
"Not decoding utterance " << utt
168 <<
" because no features available.";
173 feature_reader.Value(utt));
174 if (features->
NumRows() == 0) {
175 KALDI_WARN <<
"Zero-length utterance: " << utt;
184 new VectorFst<StdArc>(fst_reader.Value()));
189 log_sum_exp_prune, features);
193 decoder, gmm_decodable,
194 trans_model, word_syms, utt, acoustic_scale, determinize,
195 allow_partial, &alignment_writer, &words_writer,
196 &compact_lattice_writer, &lattice_writer,
197 &tot_like, &frame_count, &num_done, &num_err, NULL);
206 double elapsed = timer.
Elapsed();
209 <<
"s: real-time factor per thread assuming 100 frames/sec is " 210 << (sequencer_config.
num_threads * elapsed * 100.0 / frame_count);
211 KALDI_LOG <<
"Done " << num_done <<
" utterances, failed for " 213 KALDI_LOG <<
"Overall log-likelihood per frame is " 214 << (tot_like/frame_count) <<
" over " 215 << frame_count <<
" frames.";
218 if (num_done != 0)
return 0;
220 }
catch(
const std::exception &e) {
221 std::cerr << e.what();
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)
A templated class for writing objects to an archive or script file; see The Table concept...
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...
This class basically does the same job as the function DecodeUtteranceLatticeFaster, but in a way that allows us to build a multi-threaded command line program more easily.
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.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
LatticeFasterDecoderTpl< fst::StdFst, decoder::StdToken > LatticeFasterDecoder
void Register(OptionsItf *opts)
double Elapsed() const
Returns time in seconds.
void Read(std::istream &in_stream, bool binary)
void Register(OptionsItf *opts)