Classes | |
struct | HTransducerConfig |
Configuration class for the GetHTransducer() function; see The HTransducerConfig configuration class for context. More... | |
struct | HmmCacheHash |
Typedefs | |
typedef unordered_map< std::pair< int32, std::vector< int32 > >, fst::VectorFst< fst::StdArc > *, HmmCacheHash > | HmmCacheType |
HmmCacheType is a map from (central-phone, sequence of pdf-ids) to FST, used as cache in GetHmmAsFsa, as an optimization. More... | |
Functions | |
fst::VectorFst< fst::StdArc > * | GetHmmAsFsa (std::vector< int32 > context_window, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, const HTransducerConfig &config, HmmCacheType *cache=NULL) |
Called by GetHTransducer() and probably will not need to be called directly; it creates and returns the FST corresponding to the phone. More... | |
fst::VectorFst< fst::StdArc > * | GetHmmAsFsaSimple (std::vector< int32 > context_window, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, BaseFloat prob_scale) |
Included mainly as a form of documentation, not used in any other code currently. More... | |
fst::VectorFst< fst::StdArc > * | GetHTransducer (const std::vector< std::vector< int32 > > &ilabel_info, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, const HTransducerConfig &config, std::vector< int32 > *disambig_syms_left) |
Returns the H tranducer; result owned by caller. More... | |
void | GetIlabelMapping (const std::vector< std::vector< int32 > > &ilabel_info_old, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, std::vector< int32 > *old2new_map) |
GetIlabelMapping produces a mapping that's similar to HTK's logical-to-physical model mapping (i.e. More... | |
void | AddSelfLoops (const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, BaseFloat self_loop_scale, bool reorder, bool check_no_self_loops, fst::VectorFst< fst::StdArc > *fst) |
For context, see AddSelfLoops(). More... | |
void | AddTransitionProbs (const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, BaseFloat transition_scale, BaseFloat self_loop_scale, fst::VectorFst< fst::StdArc > *fst) |
Adds transition-probs, with the supplied scales (see Scaling of transition and acoustic probabilities), to the graph. More... | |
void | AddTransitionProbs (const TransitionModel &trans_model, BaseFloat transition_scale, BaseFloat self_loop_scale, Lattice *lat) |
This is as AddSelfLoops(), but operates on a Lattice, where it affects the graph part of the weight (the first element of the pair). More... | |
fst::VectorFst< fst::StdArc > * | GetPdfToTransitionIdTransducer (const TransitionModel &trans_model) |
Returns a transducer from pdfs plus one (input) to transition-ids (output). More... | |
void | ConvertTransitionIdsToPdfs (const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, fst::VectorFst< fst::StdArc > *fst) |
Converts all transition-ids in the FST to pdfs plus one. More... | |
typedef unordered_map<std::pair<int32, std::vector<int32> >, fst::VectorFst<fst::StdArc>*, HmmCacheHash> HmmCacheType |
HmmCacheType is a map from (central-phone, sequence of pdf-ids) to FST, used as cache in GetHmmAsFsa, as an optimization.
Definition at line 70 of file hmm-utils.h.
void AddSelfLoops | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | disambig_syms, | ||
BaseFloat | self_loop_scale, | ||
bool | reorder, | ||
bool | check_no_self_loops, | ||
fst::VectorFst< fst::StdArc > * | fst | ||
) |
For context, see AddSelfLoops().
Expands an FST that has been built without self-loops, and adds the self-loops (it also needs to modify the probability of the non-self-loop ones, as the graph without self-loops was created in such a way that it was stochastic). Note that the disambig_syms will be empty in some recipes (e.g. if you already removed the disambiguation symbols). This function will treat numbers over 10000000 (kNontermBigNumber) the same as disambiguation symbols, assuming they are special symbols for grammar decoding.
trans_model | [in] Transition model |
disambig_syms | [in] Sorted, uniq list of disambiguation symbols, required if the graph contains disambiguation symbols but only needed for sanity checks. |
self_loop_scale | [in] Transition-probability scale for self-loops; c.f. Scaling of transition and acoustic probabilities |
reorder | [in] If true, reorders the transitions (see Reordering transitions). You'll normally want this to be true. |
check_no_self_loops | [in] If true, it will check that there are no self-loops in the original graph; you'll normally want this to be true. If false, it will allow them, and will add self-loops after the original self-loop transitions, assuming reorder==true... this happens to be what we want when converting normal to unconstrained chain examples. WARNING: this was added in 2018; if you get a compilation error, add this as 'true', which emulates the behavior of older code. |
fst | [in, out] The FST to be modified. |
Definition at line 602 of file hmm-utils.cc.
References kaldi::AddSelfLoopsNoReorder(), kaldi::AddSelfLoopsReorder(), and KALDI_ASSERT.
Referenced by TrainingGraphCompiler::CompileGraph(), TrainingGraphCompiler::CompileGraphs(), kaldi::CoverageTest(), main(), and kaldi::ScoringTest().
void AddTransitionProbs | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | disambig_syms, | ||
BaseFloat | transition_scale, | ||
BaseFloat | self_loop_scale, | ||
fst::VectorFst< fst::StdArc > * | fst | ||
) |
Adds transition-probs, with the supplied scales (see Scaling of transition and acoustic probabilities), to the graph.
Useful if you want to create a graph without transition probs, then possibly train the model (including the transition probs) but keep the graph fixed, and add back in the transition probs. It assumes the fst has transition-ids on it. It is not an error if the FST has no states (nothing will be done).
trans_model | [in] The transition model |
disambig_syms | [in] A list of disambiguation symbols, required if the graph has disambiguation symbols on its input but only used for checks. |
transition_scale | [in] A scale on transition-probabilities apart from those involving self-loops; see Scaling of transition and acoustic probabilities. |
self_loop_scale | [in] A scale on self-loop transition probabilities; see Scaling of transition and acoustic probabilities. |
fst | [in, out] The FST to be modified. |
Definition at line 1088 of file hmm-utils.cc.
References kaldi::GetScaledTransitionLogProb(), kaldi::IsSortedAndUniq(), KALDI_ASSERT, KALDI_ERR, TransitionModel::NumTransitionIds(), and fst::Times().
Referenced by main().
void AddTransitionProbs | ( | const TransitionModel & | trans_model, |
BaseFloat | transition_scale, | ||
BaseFloat | self_loop_scale, | ||
Lattice * | lat | ||
) |
This is as AddSelfLoops(), but operates on a Lattice, where it affects the graph part of the weight (the first element of the pair).
Definition at line 1121 of file hmm-utils.cc.
References kaldi::GetScaledTransitionLogProb(), KALDI_ERR, and TransitionModel::NumTransitionIds().
void kaldi::ConvertTransitionIdsToPdfs | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | disambig_syms, | ||
fst::VectorFst< fst::StdArc > * | fst | ||
) |
Converts all transition-ids in the FST to pdfs plus one.
Placeholder: not implemented yet!
fst::VectorFst< fst::StdArc > * GetHmmAsFsa | ( | std::vector< int32 > | context_window, |
const ContextDependencyInterface & | ctx_dep, | ||
const TransitionModel & | trans_model, | ||
const HTransducerConfig & | config, | ||
HmmCacheType * | cache = NULL |
||
) |
Called by GetHTransducer() and probably will not need to be called directly; it creates and returns the FST corresponding to the phone.
It's actually an acceptor (ilabels equal to olabels), which is why this is called "Fsa" not "Fst". This acceptor does not include self-loops; you have to call AddSelfLoops() for that. (We do that at a later graph compilation phase, for efficiency). The labels on the FSA correspond to transition-ids.
as the symbols. For documentation in context, see The function GetHmmAsFst()
context_window | A vector representing the phonetic context; see here for explanation. |
ctx_dep | The object that contains the phonetic decision-tree |
trans_model | The transition-model object, which provides the mappings to transition-ids and also the transition probabilities. |
config | Configuration object, see HTransducerConfig. |
cache | Object used as a lookaside buffer to save computation; if it finds that the object it needs is already there, it will just return a pointer value from "cache"– not that this means you have to be careful not to delete things twice. |
Definition at line 32 of file hmm-utils.cc.
References fst::ApplyProbabilityScale(), ContextDependencyInterface::CentralPosition(), ContextDependencyInterface::Compute(), ContextDependencyInterface::ContextWidth(), TransitionModel::GetTopo(), TransitionModel::GetTransitionLogProbIgnoringSelfLoops(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, kaldi::kNoPdf, kaldi::Log(), HmmTopology::NumPdfClasses(), TransitionModel::PairToTransitionId(), fst::RemoveEpsLocal(), HmmTopology::TopologyForPhone(), HTransducerConfig::transition_scale, and TransitionModel::TupleToTransitionState().
Referenced by kaldi::GetHTransducer().
fst::VectorFst< fst::StdArc > * GetHmmAsFsaSimple | ( | std::vector< int32 > | context_window, |
const ContextDependencyInterface & | ctx_dep, | ||
const TransitionModel & | trans_model, | ||
BaseFloat | prob_scale | ||
) |
Included mainly as a form of documentation, not used in any other code currently.
Creates the acceptor FST with self-loops, and with fewer options.
Definition at line 155 of file hmm-utils.cc.
References ContextDependencyInterface::CentralPosition(), ContextDependencyInterface::Compute(), ContextDependencyInterface::ContextWidth(), TransitionModel::GetTopo(), TransitionModel::GetTransitionLogProb(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, kaldi::kNoPdf, kaldi::Log(), TransitionModel::PairToTransitionId(), HmmTopology::TopologyForPhone(), and TransitionModel::TupleToTransitionState().
Referenced by kaldi::GetRandomAlignmentForPhone().
fst::VectorFst< fst::StdArc > * GetHTransducer | ( | const std::vector< std::vector< int32 > > & | ilabel_info, |
const ContextDependencyInterface & | ctx_dep, | ||
const TransitionModel & | trans_model, | ||
const HTransducerConfig & | config, | ||
std::vector< int32 > * | disambig_syms_left | ||
) |
Returns the H tranducer; result owned by caller.
Caution: our version of the H transducer does not include self-loops; you have to add those later. See GetHTransducer(). The H transducer has on the input transition-ids, and also possibly some disambiguation symbols, which will be put in disambig_syms. The output side contains the identifiers that are indexes into "ilabel_info" (these represent phones-in-context or disambiguation symbols). The ilabel_info vector allows GetHTransducer to map from symbols to phones-in-context (i.e. phonetic context windows). Any singleton symbols in the ilabel_info vector which are not phones, will be treated as disambiguation symbols. [Not all recipes use these]. The output "disambig_syms_left" will be set to a list of the disambiguation symbols on the input of the transducer (i.e. same symbol type as whatever is on the input of the transducer
Definition at line 254 of file hmm-utils.cc.
References kaldi::DeletePointers(), fst::GetEncodingMultiple(), kaldi::GetHmmAsFsa(), TransitionModel::GetPhones(), rnnlm::j, KALDI_ASSERT, KALDI_ERR, fst::kNontermBigNumber, fst::MakeLoopFst(), kaldi::MakeTrivialAcceptor(), HTransducerConfig::nonterm_phones_offset, TransitionModel::NumTransitionIds(), and kaldi::SortAndUniq().
Referenced by TrainingGraphCompiler::CompileGraph(), TrainingGraphCompiler::CompileGraphs(), and main().
void GetIlabelMapping | ( | const std::vector< std::vector< int32 > > & | ilabel_info_old, |
const ContextDependencyInterface & | ctx_dep, | ||
const TransitionModel & | trans_model, | ||
std::vector< int32 > * | old2new_map | ||
) |
GetIlabelMapping produces a mapping that's similar to HTK's logical-to-physical model mapping (i.e.
the xwrd.clustered.mlist files). It groups together "logical HMMs" (i.e. in our world, phonetic context windows) that share the same sequence of transition-ids. This can be used in an optional graph-creation step that produces a remapped form of CLG that can be more productively determinized and minimized. This is used in the command-line program make-ilabel-transducer.cc.
ilabel_info_old | [in] The original ilabel_info vector |
ctx_dep | [in] The tree |
trans_model | [in] The transition-model object |
old2new_map | [out] The output; this vector, which is of size equal to the number of new labels, is a mapping to the old labels such that we could create a vector ilabel_info_new such that ilabel_info_new[i] == ilabel_info_old[old2new_map[i]] |
The next variable maps from the (central-phone, pdf-sequence) to the index in ilabel_info_old corresponding to the first phone-in-context that we saw for it. We use this to work out the logical-to-physical mapping. Each time we handle a phone in context, we see if its (central-phone, pdf-sequence) has already been seen; if yes, we map to the original phone-sequence, if no, we create a new "phyiscal-HMM" and there is no mapping.
old2old_map is a map from the old ilabels to themselves (but duplicates are mapped to one unique one.
Definition at line 335 of file hmm-utils.cc.
References ContextDependencyInterface::CentralPosition(), ContextDependencyInterface::Compute(), ContextDependencyInterface::ContextWidth(), TransitionModel::GetTopo(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, HmmTopology::NumPdfClasses(), and kaldi::WriteIntegerVector().
Referenced by main().
fst::VectorFst< fst::StdArc > * GetPdfToTransitionIdTransducer | ( | const TransitionModel & | trans_model | ) |
Returns a transducer from pdfs plus one (input) to transition-ids (output).
Currenly of use only for testing.
Definition at line 407 of file hmm-utils.cc.
References TransitionModel::NumTransitionIds(), and TransitionModel::TransitionIdToPdf().
Referenced by main().