lattice-functions.cc File Reference
Include dependency graph for lattice-functions.cc:

Go to the source code of this file.

Classes

struct  LatticeArcRecord
 This is used in CompactLatticeLimitDepth. More...
 
struct  ClatRescoreTuple
 

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Functions

void GetPerFrameAcousticCosts (const Lattice &nbest, Vector< BaseFloat > *per_frame_loglikes)
 This function extracts the per-frame log likelihoods from a linear lattice (which we refer to as an 'nbest' lattice elsewhere in Kaldi code). More...
 
int32 LatticeStateTimes (const Lattice &lat, vector< int32 > *times)
 This function iterates over the states of a topologically sorted lattice and counts the time instance corresponding to each state. More...
 
int32 CompactLatticeStateTimes (const CompactLattice &lat, vector< int32 > *times)
 As LatticeStateTimes, but in the CompactLattice format. More...
 
bool ComputeCompactLatticeAlphas (const CompactLattice &clat, vector< double > *alpha)
 
bool ComputeCompactLatticeBetas (const CompactLattice &clat, vector< double > *beta)
 
template<class LatType >
bool PruneLattice (BaseFloat beam, LatType *lat)
 
template bool PruneLattice (BaseFloat beam, Lattice *lat)
 
template bool PruneLattice (BaseFloat beam, CompactLattice *lat)
 
BaseFloat LatticeForwardBackward (const Lattice &lat, Posterior *arc_post, double *acoustic_like_sum=NULL)
 This function does the forward-backward over lattices and computes the posterior probabilities of the arcs. More...
 
void LatticeActivePhones (const Lattice &lat, const TransitionModel &trans, const vector< int32 > &silence_phones, vector< std::set< int32 > > *active_phones)
 Given a lattice, and a transition model to map pdf-ids to phones, outputs for each frame the set of phones active on that frame. More...
 
void ConvertLatticeToPhones (const TransitionModel &trans_model, Lattice *lat)
 Given a lattice, and a transition model to map pdf-ids to phones, replace the output symbols (presumably words), with phones; we use the TransitionModel to work out the phone sequence. More...
 
static double LogAddOrMax (bool viterbi, double a, double b)
 
template<typename LatticeType >
double ComputeLatticeAlphasAndBetas (const LatticeType &lat, bool viterbi, vector< double > *alpha, vector< double > *beta)
 
template double ComputeLatticeAlphasAndBetas (const Lattice &lat, bool viterbi, vector< double > *alpha, vector< double > *beta)
 
template double ComputeLatticeAlphasAndBetas (const CompactLattice &lat, bool viterbi, vector< double > *alpha, vector< double > *beta)
 
void CompactLatticeLimitDepth (int32 max_arcs_per_frame, CompactLattice *clat)
 This function limits the depth of the lattice, per frame: that means, it does not allow more than a specified number of arcs active on any given frame. More...
 
void TopSortCompactLatticeIfNeeded (CompactLattice *clat)
 Topologically sort the compact lattice if not already topologically sorted. More...
 
void TopSortLatticeIfNeeded (Lattice *clat)
 Topologically sort the lattice if not already topologically sorted. More...
 
BaseFloat CompactLatticeDepth (const CompactLattice &clat, int32 *num_frames)
 Returns the depth of the lattice, defined as the average number of arcs crossing any given frame. More...
 
void CompactLatticeDepthPerFrame (const CompactLattice &clat, std::vector< int32 > *depth_per_frame)
 This function returns, for each frame, the number of arcs crossing that frame. More...
 
void ConvertCompactLatticeToPhones (const TransitionModel &trans_model, CompactLattice *clat)
 Given a lattice, and a transition model to map pdf-ids to phones, replace the sequences of transition-ids with sequences of phones. More...
 
bool LatticeBoost (const TransitionModel &trans, const std::vector< int32 > &alignment, const std::vector< int32 > &silence_phones, BaseFloat b, BaseFloat max_silence_error, Lattice *lat)
 Boosts LM probabilities by b * [number of frame errors]; equivalently, adds -b*[number of frame errors] to the graph-component of the cost of each arc/path. More...
 
BaseFloat LatticeForwardBackwardMpeVariants (const TransitionModel &trans, const std::vector< int32 > &silence_phones, const Lattice &lat, const std::vector< int32 > &num_ali, std::string criterion, bool one_silence_class, Posterior *post)
 This function implements either the MPFE (minimum phone frame error) or SMBR (state-level minimum bayes risk) forward-backward, depending on whether "criterion" is "mpfe" or "smbr". More...
 
bool CompactLatticeToWordAlignment (const CompactLattice &clat, std::vector< int32 > *words, std::vector< int32 > *begin_times, std::vector< int32 > *lengths)
 This function takes a CompactLattice that should only contain a single linear sequence (e.g. More...
 
bool CompactLatticeToWordProns (const TransitionModel &tmodel, const CompactLattice &clat, std::vector< int32 > *words, std::vector< int32 > *begin_times, std::vector< int32 > *lengths, std::vector< std::vector< int32 > > *prons, std::vector< std::vector< int32 > > *phone_lengths)
 This function takes a CompactLattice that should only contain a single linear sequence (e.g. More...
 
void CompactLatticeShortestPath (const CompactLattice &clat, CompactLattice *shortest_path)
 A form of the shortest-path/best-path algorithm that's specially coded for CompactLattice. More...
 
void AddWordInsPenToCompactLattice (BaseFloat word_ins_penalty, CompactLattice *clat)
 This function add the word insertion penalty to graph score of each word in the compact lattice. More...
 
bool RescoreCompactLatticeInternal (const TransitionModel *tmodel, BaseFloat speedup_factor, DecodableInterface *decodable, CompactLattice *clat)
 RescoreCompactLatticeInternal is the internal code for both RescoreCompactLattice and RescoreCompatLatticeSpeedup. More...
 
bool RescoreCompactLatticeSpeedup (const TransitionModel &tmodel, BaseFloat speedup_factor, DecodableInterface *decodable, CompactLattice *clat)
 This function is like RescoreCompactLattice, but it is modified to avoid computing probabilities on most frames where all the pdf-ids are the same. More...
 
bool RescoreCompactLattice (DecodableInterface *decodable, CompactLattice *clat)
 This function *adds* the negated scores obtained from the Decodable object, to the acoustic scores on the arcs. More...
 
bool RescoreLattice (DecodableInterface *decodable, Lattice *lat)
 This function *adds* the negated scores obtained from the Decodable object, to the acoustic scores on the arcs. More...
 
BaseFloat LatticeForwardBackwardMmi (const TransitionModel &trans, const Lattice &lat, const std::vector< int32 > &num_ali, bool drop_frames, bool convert_to_pdf_ids, bool cancel, Posterior *arc_post)
 This function can be used to compute posteriors for MMI, with a positive contribution for the numerator and a negative one for the denominator. More...
 
int32 LongestSentenceLength (const Lattice &lat)
 This function returns the number of words in the longest sentence in a CompactLattice (i.e. More...
 
int32 LongestSentenceLength (const CompactLattice &lat)
 This function returns the number of words in the longest sentence in a CompactLattice, i.e. More...
 
void ComposeCompactLatticeDeterministic (const CompactLattice &clat, fst::DeterministicOnDemandFst< fst::StdArc > *det_fst, CompactLattice *composed_clat)
 This function Composes a CompactLattice format lattice with a DeterministicOnDemandFst<fst::StdFst> format fst, and outputs another CompactLattice format lattice. More...
 
void ComputeAcousticScoresMap (const Lattice &lat, unordered_map< std::pair< int32, int32 >, std::pair< BaseFloat, int32 >, PairHasher< int32 > > *acoustic_scores)
 This function computes the mapping from the pair (frame-index, transition-id) to the pair (sum-of-acoustic-scores, num-of-occurences) over all occurences of the transition-id in that frame. More...
 
void ReplaceAcousticScoresFromMap (const unordered_map< std::pair< int32, int32 >, std::pair< BaseFloat, int32 >, PairHasher< int32 > > &acoustic_scores, Lattice *lat)
 This function restores acoustic scores computed using the function ComputeAcousticScoresMap into the lattice. More...