online-gmm-decoding.cc
Go to the documentation of this file.
1 // online2/online-gmm-decoding.cc
2 
3 // Copyright 2013-2014 Johns Hopkins University (author: Daniel Povey)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
21 #include "lat/lattice-functions.h"
23 
24 namespace kaldi {
25 
26 void OnlineGmmAdaptationState::Read(std::istream &in_stream, bool binary) {
27  ExpectToken(in_stream, binary, "<ONLINEGMMADAPTATIONSTATE>");
28  ExpectToken(in_stream, binary, "<TRANSFORM>");
29  transform.Read(in_stream, binary);
30  ExpectToken(in_stream, binary, "<CMVNSTATS>");
31  cmvn_state.Read(in_stream, binary);
32  ExpectToken(in_stream, binary, "<SPKSTATS>");
33  spk_stats.Read(in_stream, binary, false);
34  ExpectToken(in_stream, binary, "</ONLINEGMMADAPTATIONSTATE>");
35 }
36 
37 void OnlineGmmAdaptationState::Write(std::ostream &out_stream, bool binary) const {
38  WriteToken(out_stream, binary, "<ONLINEGMMADAPTATIONSTATE>");
39  WriteToken(out_stream, binary, "<TRANSFORM>");
40  transform.Write(out_stream, binary);
41  WriteToken(out_stream, binary, "<CMVNSTATS>");
42  cmvn_state.Write(out_stream, binary);
43  WriteToken(out_stream, binary, "<SPKSTATS>");
44  spk_stats.Write(out_stream, binary);
45  WriteToken(out_stream, binary, "</ONLINEGMMADAPTATIONSTATE>");
46 }
47 
49  const OnlineGmmDecodingConfig &config,
50  const OnlineGmmDecodingModels &models,
51  const OnlineFeaturePipeline &feature_prototype,
52  const fst::Fst<fst::StdArc> &fst,
53  const OnlineGmmAdaptationState &adaptation_state):
54  config_(config), models_(models),
55  feature_pipeline_(feature_prototype.New()),
56  orig_adaptation_state_(adaptation_state),
57  adaptation_state_(adaptation_state),
58  decoder_(fst, config.faster_decoder_opts) {
61  KALDI_ERR << "Bad --silence-phones option '"
62  << config_.silence_phones << "'";
66 }
67 
68 // Advance the decoding as far as we can, and possibly estimate fMLLR.
70 
71  const AmDiagGmm &am_gmm = (HaveTransform() ? models_.GetModel() :
73 
74  // The decodable object is lightweight, we lose nothing
75  // from constructing it each time we want to decode more of the
76  // input.
77  DecodableDiagGmmScaledOnline decodable(am_gmm,
81 
82  int32 old_frames = decoder_.NumFramesDecoded();
83 
84  // This will decode as many frames as are currently available.
85  decoder_.AdvanceDecoding(&decodable);
86 
87 
88  { // possibly estimate fMLLR.
89  int32 new_frames = decoder_.NumFramesDecoded();
91  // if the original adaptation state (at utterance-start) had no transform,
92  // then this means it's the first utt of the speaker... even if not, if we
93  // don't have a transform it probably makes sense to treat it as the 1st utt
94  // of the speaker, i.e. to do fMLLR adaptation sooner.
95  bool is_first_utterance_of_speaker =
97  bool end_of_utterance = false;
98  if (config_.adaptation_policy_opts.DoAdapt(old_frames * frame_shift,
99  new_frames * frame_shift,
100  is_first_utterance_of_speaker))
101  this->EstimateFmllr(end_of_utterance);
102  }
103 }
104 
107 }
108 
109 // gets Gaussian posteriors for purposes of fMLLR estimation.
110 // We exclude the silence phones from the Gaussian posteriors.
112  GaussPost *gpost) {
113  // Gets the Gaussian-level posteriors for this utterance, using whatever
114  // features and model we are currently decoding with. We'll use these
115  // to estimate basis-fMLLR with.
116  if (decoder_.NumFramesDecoded() == 0) {
117  KALDI_WARN << "You have decoded no data so cannot estimate fMLLR.";
118  return false;
119  }
120 
122 
123  // Note: we'll just use whatever acoustic scaling factor we were decoding
124  // with. This is in the lattice that we get from decoder_.GetRawLattice().
125  Lattice raw_lat;
126  decoder_.GetRawLatticePruned(&raw_lat, end_of_utterance,
128 
129  // At this point we could rescore the lattice if we wanted, and
130  // this might improve the accuracy on long utterances that were
131  // the first utterance of that speaker, if we had already
132  // estimated the fMLLR by the time we reach this code (e.g. this
133  // was the second call). We don't do this right now.
134 
136 
137 #if 1 // Do determinization.
138  Lattice det_lat; // lattice-determinized lattice-- represent this as Lattice
139  // not CompactLattice, as LatticeForwardBackward() does not
140  // accept CompactLattice.
141 
142 
143  fst::Invert(&raw_lat); // want to determinize on words.
144  fst::ILabelCompare<kaldi::LatticeArc> ilabel_comp;
145  fst::ArcSort(&raw_lat, ilabel_comp); // improves efficiency of determinization
146 
148  double(config_.fmllr_lattice_beam),
149  &det_lat);
150 
151  fst::Invert(&det_lat); // invert back.
152 
153  if (det_lat.NumStates() == 0) {
154  // Do nothing if the lattice is empty. This should not happen.
155  KALDI_WARN << "Got empty lattice. Not estimating fMLLR.";
156  return false;
157  }
158 #else
159  Lattice &det_lat = raw_lat; // Don't determinize.
160 #endif
161  TopSortLatticeIfNeeded(&det_lat);
162 
163  // Note: the acoustic scale we use here is whatever we decoded with.
164  Posterior post;
165  BaseFloat tot_fb_like = LatticeForwardBackward(det_lat, &post);
166 
167  KALDI_VLOG(3) << "Lattice forward-backward likelihood was "
168  << (tot_fb_like / post.size()) << " per frame over " << post.size()
169  << " frames.";
170 
171  ConstIntegerSet<int32> silence_set(silence_phones_); // faster lookup
172  const TransitionModel &trans_model = models_.GetTransitionModel();
173  WeightSilencePost(trans_model, silence_set,
174  config_.silence_weight, &post);
175 
176  const AmDiagGmm &am_gmm = (HaveTransform() ? models_.GetModel() :
178 
179 
180  Posterior pdf_post;
181  ConvertPosteriorToPdfs(trans_model, post, &pdf_post);
182 
184 
185  double tot_like = 0.0, tot_weight = 0.0;
186  gpost->resize(pdf_post.size());
187  for (size_t i = 0; i < pdf_post.size(); i++) {
188  feature_pipeline_->GetFrame(i, &feat);
189  for (size_t j = 0; j < pdf_post[i].size(); j++) {
190  int32 pdf_id = pdf_post[i][j].first;
191  BaseFloat weight = pdf_post[i][j].second;
192  const DiagGmm &gmm = am_gmm.GetPdf(pdf_id);
193  Vector<BaseFloat> this_post_vec;
194  BaseFloat like = gmm.ComponentPosteriors(feat, &this_post_vec);
195  this_post_vec.Scale(weight);
196  tot_like += like * weight;
197  tot_weight += weight;
198  (*gpost)[i].push_back(std::make_pair(pdf_id, this_post_vec));
199  }
200  }
201  KALDI_VLOG(3) << "Average likelihood weighted by posterior was "
202  << (tot_like / tot_weight) << " over " << tot_weight
203  << " frames (after downweighting silence).";
204  return true;
205 }
206 
207 
208 void SingleUtteranceGmmDecoder::EstimateFmllr(bool end_of_utterance) {
209  if (decoder_.NumFramesDecoded() == 0) {
210  KALDI_WARN << "You have decoded no data so cannot estimate fMLLR.";
211  }
212 
213  if (GetVerboseLevel() >= 2) {
214  Matrix<BaseFloat> feats;
216  KALDI_VLOG(2) << "Features are " << feats;
217  }
218 
219 
220  GaussPost gpost;
221  GetGaussianPosteriors(end_of_utterance, &gpost);
222 
224 
225  if (spk_stats.beta_ !=
227  // This could happen if the user called EstimateFmllr() twice on the
228  // same utterance... we don't want to count any stats twice so we
229  // have to reset the stats to what they were before this utterance
230  // (possibly empty).
231  spk_stats = orig_adaptation_state_.spk_stats;
232  }
233 
234  int32 dim = feature_pipeline_->Dim();
235  if (spk_stats.Dim() == 0)
236  spk_stats.Init(dim);
237 
238  Matrix<BaseFloat> empty_transform;
239  feature_pipeline_->SetTransform(empty_transform);
240  Vector<BaseFloat> feat(dim);
241 
242  if (adaptation_state_.transform.NumRows() == 0) {
243  // If this is the first time we're estimating fMLLR, freeze the CMVN to its
244  // current value. It doesn't matter too much what value this is, since we
245  // have already computed the Gaussian-level alignments (it may have a small
246  // effect if the basis is very small and doesn't include an offset as part
247  // of the transform).
249  }
250 
251  // GetModel() returns the model to be used for estimating
252  // transforms.
253  const AmDiagGmm &am_gmm = models_.GetModel();
254 
255  for (size_t i = 0; i < gpost.size(); i++) {
256  feature_pipeline_->GetFrame(i, &feat);
257  for (size_t j = 0; j < gpost[i].size(); j++) {
258  int32 pdf_id = gpost[i][j].first; // caution: this gpost has pdf-id
259  // instead of transition-id, which is
260  // unusual.
261  const Vector<BaseFloat> &posterior(gpost[i][j].second);
262  spk_stats.AccumulateFromPosteriors(am_gmm.GetPdf(pdf_id),
263  feat, posterior);
264  }
265  }
266 
267  const BasisFmllrEstimate &basis = models_.GetFmllrBasis();
268  if (basis.Dim() == 0)
269  KALDI_ERR << "In order to estimate fMLLR, you need to supply the "
270  << "--fmllr-basis option.";
271  Vector<BaseFloat> basis_coeffs;
272  BaseFloat impr = basis.ComputeTransform(spk_stats,
274  &basis_coeffs, config_.basis_opts);
275  KALDI_VLOG(3) << "Objective function improvement from basis-fMLLR is "
276  << (impr / spk_stats.beta_) << " per frame, over "
277  << spk_stats.beta_ << " frames, #params estimated is "
278  << basis_coeffs.Dim();
280 }
281 
282 
285 }
286 
288  OnlineGmmAdaptationState *adaptation_state) const {
289  *adaptation_state = adaptation_state_;
290  feature_pipeline_->GetCmvnState(&adaptation_state->cmvn_state);
291 }
292 
295  adaptation_state_.transform.NumRows()) return true; // fMLLR was estimated
297  adaptation_state_.transform)) return true; // fMLLR was re-estimated
298  if (adaptation_state_.transform.NumRows() != 0 &&
300  return true; // we have an fMLLR transform, and a discriminatively estimated
301  // model which differs from the one used to estimate fMLLR.
302  return false;
303 }
304 
306  delete feature_pipeline_;
307 }
308 
309 
311  const OnlineEndpointConfig &config) {
312  const TransitionModel &tmodel = models_.GetTransitionModel();
313  return kaldi::EndpointDetected(config, tmodel,
315  decoder_);
316 }
317 
318 void SingleUtteranceGmmDecoder::GetLattice(bool rescore_if_needed,
319  bool end_of_utterance,
320  CompactLattice *clat) const {
321  Lattice lat;
322  double lat_beam = config_.faster_decoder_opts.lattice_beam;
323  decoder_.GetRawLattice(&lat, end_of_utterance);
324  if (rescore_if_needed && RescoringIsNeeded()) {
329 
330  if (!kaldi::RescoreLattice(&decodable, &lat))
331  KALDI_WARN << "Error rescoring lattice";
332  }
333  PruneLattice(lat_beam, &lat);
334 
336  &lat, lat_beam, clat,
338 
339 }
340 
341 void SingleUtteranceGmmDecoder::GetBestPath(bool end_of_utterance,
342  Lattice *best_path) const {
343  decoder_.GetBestPath(best_path, end_of_utterance);
344 }
345 
347  const OnlineGmmDecodingConfig &config) {
348  KALDI_ASSERT(!config.model_rxfilename.empty() &&
349  "You must supply the --model option");
350 
351  {
352  bool binary;
353  Input ki(config.model_rxfilename, &binary);
354  tmodel_.Read(ki.Stream(), binary);
355  model_.Read(ki.Stream(), binary);
356  }
357 
358  if (!config.online_alimdl_rxfilename.empty()) {
359  bool binary;
360  Input ki(config.online_alimdl_rxfilename, &binary);
361  TransitionModel tmodel;
362  tmodel.Read(ki.Stream(), binary);
363  if (!tmodel.Compatible(tmodel_))
364  KALDI_ERR << "Incompatible models given to the --model and "
365  << "--online-alignment-model options";
366  online_alignment_model_.Read(ki.Stream(), binary);
367  }
368 
369  if (!config.rescore_model_rxfilename.empty()) {
370  bool binary;
371  Input ki(config.rescore_model_rxfilename, &binary);
372  TransitionModel tmodel;
373  tmodel.Read(ki.Stream(), binary);
374  if (!tmodel.Compatible(tmodel_))
375  KALDI_ERR << "Incompatible models given to the --model and "
376  << "--final-model options";
377  rescore_model_.Read(ki.Stream(), binary);
378  }
379 
380  if (!config.fmllr_basis_rxfilename.empty()) {
381  // We could just as easily use ReadKaldiObject() here.
382  bool binary;
383  Input ki(config.fmllr_basis_rxfilename, &binary);
384  fmllr_basis_.Read(ki.Stream(), binary);
385  }
386 }
387 
388 
390  return tmodel_;
391 }
392 
394  if (online_alignment_model_.NumPdfs() != 0)
395  return online_alignment_model_;
396  else
397  return model_;
398 }
399 
401  return model_;
402 }
403 
405  if (rescore_model_.NumPdfs() != 0)
406  return rescore_model_;
407  else
408  return model_;
409 }
410 
412  return fmllr_basis_;
413 }
414 
415 
417  KALDI_ASSERT(adaptation_first_utt_delay > 0.0 &&
418  adaptation_first_utt_ratio > 1.0);
419  KALDI_ASSERT(adaptation_delay > 0.0 &&
420  adaptation_ratio > 1.0);
421 }
422 
424  BaseFloat chunk_begin_secs,
425  BaseFloat chunk_end_secs,
426  bool is_first_utterance) const {
427  Check();
428  if (is_first_utterance) {
429  // We aim to return true if a member of the sequence
430  // ( adaptation_first_utt_delay * adaptation_first_utt_ratio^n )
431  // for n = 0, 1, 2, ...
432  // is in the range [ chunk_begin_secs, chunk_end_secs ).
433  BaseFloat delay = adaptation_first_utt_delay;
434  while (delay < chunk_begin_secs)
435  delay *= adaptation_first_utt_ratio;
436  return (delay < chunk_end_secs);
437  } else {
438  // as above, but remove "first_utt".
439  BaseFloat delay = adaptation_delay;
440  while (delay < chunk_begin_secs)
441  delay *= adaptation_ratio;
442  return (delay < chunk_end_secs);
443  }
444 }
445 
446 
447 } // namespace kaldi
const AmDiagGmm & GetModel() const
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
virtual int32 Dim() const
Member functions from OnlineFeatureInterface:
void Write(std::ostream &out, bool binary) const
write to stream.
const BasisFmllrEstimate & GetFmllrBasis() const
void Write(std::ostream &os, bool binary) const
bool GetRawLattice(Lattice *ofst, bool use_final_probs=true) const
Outputs an FST corresponding to the raw, state-level tracebacks.
void AdvanceDecoding()
advance the decoding as far as we can.
This class is used to read, store and give access to the models used for 3 phases of decoding (first-...
SingleUtteranceGmmDecoder(const OnlineGmmDecodingConfig &config, const OnlineGmmDecodingModels &models, const OnlineFeaturePipeline &feature_prototype, const fst::Fst< fst::StdArc > &fst, const OnlineGmmAdaptationState &adaptation_state)
bool DeterminizeLatticePruned(const ExpandedFst< ArcTpl< Weight > > &ifst, double beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePrunedOptions opts)
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
bool RescoringIsNeeded() const
Returns true if doing a lattice rescoring pass would have any point, i.e.
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
Definition: text-utils.h:68
int32 GetVerboseLevel()
Get verbosity level, usually set via command line &#39;–verbose=&#39; switch.
Definition: kaldi-error.h:60
void GetAdaptationState(OnlineGmmAdaptationState *adaptation_state) const
bool ApproxEqual(const MatrixBase< Real > &other, float tol=0.01) const
Returns true if ((*this)-other).FrobeniusNorm() <= tol * (*this).FrobeniusNorm(). ...
This does not work with multiple feature transforms.
void TopSortLatticeIfNeeded(Lattice *lat)
Topologically sort the lattice if not already topologically sorted.
void AccumulateFromPosteriors(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &posteriors)
Accumulate stats for a GMM, given supplied posteriors.
OnlineGmmDecodingModels(const OnlineGmmDecodingConfig &config)
OnlineGmmAdaptationState adaptation_state_
kaldi::int32 int32
void FinalizeDecoding()
This function may be optionally called after AdvanceDecoding(), when you do not plan to decode any fu...
bool GetGaussianPosteriors(bool end_of_utterance, GaussPost *gpost)
bool EndpointDetected(const OnlineEndpointConfig &config, int32 num_frames_decoded, int32 trailing_silence_frames, BaseFloat frame_shift_in_seconds, BaseFloat final_relative_cost)
This function returns true if this set of endpointing rules thinks we should terminate decoding...
void Check() const
Check that configuration values make sense.
void SortAndUniq(std::vector< T > *vec)
Sorts and uniq&#39;s (removes duplicates) from a vector.
Definition: stl-utils.h:39
double ComputeTransform(const AffineXformStats &spk_stats, Matrix< BaseFloat > *out_xform, Vector< BaseFloat > *coefficients, BasisFmllrOptions options) const
This function performs speaker adaptation, computing the fMLLR matrix based on speaker statistics...
OnlineFeaturePipeline is a class that&#39;s responsible for putting together the various stages of the fe...
void WeightSilencePost(const TransitionModel &trans_model, const ConstIntegerSet< int32 > &silence_set, BaseFloat silence_scale, Posterior *post)
Weight any silence phones in the posterior (i.e.
Definition: posterior.cc:375
const AmDiagGmm & GetOnlineAlignmentModel() const
void GetCmvnState(OnlineCmvnState *cmvn_state)
std::istream & Stream()
Definition: kaldi-io.cc:826
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *posteriors) const
Computes the posterior probabilities of all Gaussian components given a data point.
Definition: diag-gmm.cc:601
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
Definition: posterior.h:42
void InitDecoding()
InitDecoding initializes the decoding, and should only be used if you intend to call AdvanceDecoding(...
void Read(std::istream &is, bool binary)
BaseFloat LatticeForwardBackward(const Lattice &lat, Posterior *post, double *acoustic_like_sum)
This function does the forward-backward over lattices and computes the posterior probabilities of the...
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)
Gets the feature vector for this frame.
void FinalizeDecoding()
Finalize the decoding.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:191
void Read(std::istream &is, bool binary)
fst::VectorFst< LatticeArc > Lattice
Definition: kaldi-lattice.h:44
#define KALDI_ERR
Definition: kaldi-error.h:147
bool Compatible(const TransitionModel &other) const
returns true if all the integer class members are identical (but does not compare the transition prob...
#define KALDI_WARN
Definition: kaldi-error.h:150
void Write(std::ostream &out, bool binary) const
void GetAsMatrix(Matrix< BaseFloat > *feats)
LatticeFasterDecoderConfig faster_decoder_opts
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
OnlineFeaturePipeline * feature_pipeline_
MatrixIndexT Dim() const
Returns the dimension of the vector.
Definition: kaldi-vector.h:64
void Scale(Real alpha)
Multiplies all elements by this constant.
fst::VectorFst< CompactLatticeArc > CompactLattice
Definition: kaldi-lattice.h:46
bool DoAdapt(BaseFloat chunk_begin_secs, BaseFloat chunk_end_secs, bool is_first_utterance) const
This function returns true if we are scheduled to re-estimate fMLLR somewhere in the interval [ chunk...
OnlineGmmDecodingAdaptationPolicyConfig adaptation_policy_opts
void EstimateFmllr(bool end_of_utterance)
Estimate the [basis-]fMLLR transform and apply it to the features.
fst::DeterminizeLatticePhonePrunedOptions det_opts
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
Definition: am-diag-gmm.h:119
const TransitionModel & GetTransitionModel() const
void AdvanceDecoding(DecodableInterface *decodable, int32 max_num_frames=-1)
This will decode until there are no more frames ready in the decodable object.
A class representing a vector.
Definition: kaldi-vector.h:406
bool PruneLattice(BaseFloat beam, LatType *lat)
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
void Read(std::istream &in_stream, bool binary)
void GetBestPath(bool end_of_utterance, Lattice *best_path) const
Outputs an FST corresponding to the single best path through the current lattice. ...
void SetTransform(const MatrixBase< BaseFloat > &transform)
#define KALDI_VLOG(v)
Definition: kaldi-error.h:156
Definition for Gaussian Mixture Model with diagonal covariances.
Definition: diag-gmm.h:42
void Init(size_t dim)
const OnlineGmmDecodingModels & models_
void Write(std::ostream &out_stream, bool binary) const
bool GetBestPath(Lattice *ofst, bool use_final_probs=true) const
Outputs an FST corresponding to the single best path through the lattice.
bool EndpointDetected(const OnlineEndpointConfig &config)
This function calls EndpointDetected from online-endpoint.h, with the required arguments.
const OnlineGmmAdaptationState & orig_adaptation_state_
std::vector< std::vector< std::pair< int32, Vector< BaseFloat > > > > GaussPost
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance.
Definition: posterior.h:51
const AmDiagGmm & GetFinalModel() const
void ConvertPosteriorToPdfs(const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out)
Converts a posterior over transition-ids to be a posterior over pdf-ids.
Definition: posterior.cc:322
void GetLattice(bool rescore_if_needed, bool end_of_utterance, CompactLattice *clat) const
Gets the lattice.
LatticeFasterOnlineDecoder decoder_
double beta_
beta_ is the occupation count.
bool RescoreLattice(DecodableInterface *decodable, Lattice *lat)
This function *adds* the negated scores obtained from the Decodable object, to the acoustic scores on...
bool DeterminizeLatticePhonePrunedWrapper(const kaldi::TransitionModel &trans_model, MutableFst< kaldi::LatticeArc > *ifst, double beam, MutableFst< kaldi::CompactLatticeArc > *ofst, DeterminizeLatticePhonePrunedOptions opts)
This function is a wrapper of DeterminizeLatticePhonePruned() that works for Lattice type FSTs...
bool GetRawLatticePruned(Lattice *ofst, bool use_final_probs, BaseFloat beam) const
Behaves the same as GetRawLattice but only processes tokens whose extra_cost is smaller than the best...
bool HaveTransform() const
Returns true if we already have an fMLLR transform.
void Read(std::istream &in, bool binary, bool add)
Estimation functions for basis fMLLR.