Modules | |
Classes and functions for creating FSTs from HMMs | |
Classes | |
class | HmmTopology |
A class for storing topology information for phones. More... | |
struct | MleTransitionUpdateConfig |
struct | MapTransitionUpdateConfig |
class | TransitionModel |
Functions | |
bool | SplitToPhones (const TransitionModel &trans_model, const std::vector< int32 > &alignment, std::vector< std::vector< int32 > > *split_alignment) |
SplitToPhones splits up the TransitionIds in "alignment" into their individual phones (one vector per instance of a phone). More... | |
bool | ConvertAlignment (const TransitionModel &old_trans_model, const TransitionModel &new_trans_model, const ContextDependencyInterface &new_ctx_dep, const std::vector< int32 > &old_alignment, int32 subsample_factor, bool repeat_frames, bool reorder, const std::vector< int32 > *phone_map, std::vector< int32 > *new_alignment) |
ConvertAlignment converts an alignment that was created using one model, to another model. More... | |
bool | ConvertPhnxToProns (const std::vector< int32 > &phnx, const std::vector< int32 > &words, int32 word_start_sym, int32 word_end_sym, std::vector< std::vector< int32 > > *prons) |
void | GetRandomAlignmentForPhone (const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, const std::vector< int32 > &phone_window, std::vector< int32 > *alignment) |
void | ChangeReorderingOfAlignment (const TransitionModel &trans_model, std::vector< int32 > *alignment) |
void | GetPdfToPhonesMap (const TransitionModel &trans_model, std::vector< std::set< int32 > > *pdf2phones) |
bool | GetPdfsForPhones (const TransitionModel &trans_model, const std::vector< int32 > &phones, std::vector< int32 > *pdfs) |
Works out which pdfs might correspond to the given phones. More... | |
bool | GetPhonesForPdfs (const TransitionModel &trans_model, const std::vector< int32 > &pdfs, std::vector< int32 > *phones) |
Works out which phones might correspond to the given pdfs. More... | |
Variables | |
static const int32 | kNoPdf = -1 |
A constant used in the HmmTopology class as the pdf-class kNoPdf, which is used when a HMM-state is nonemitting (has no associated PDF). More... | |
Integer mapping functions | |
int32 | TransitionIdToPdf (int32 trans_id) const |
int32 | TransitionIdToPdfFast (int32 trans_id) const |
void ChangeReorderingOfAlignment | ( | const TransitionModel & | trans_model, |
std::vector< int32 > * | alignment | ||
) |
Definition at line 1260 of file hmm-utils.cc.
References TransitionModel::IsSelfLoop(), kaldi::swap(), and TransitionModel::TransitionIdToTransitionState().
Referenced by kaldi::ConvertAlignmentForPhone().
bool ConvertAlignment | ( | const TransitionModel & | old_trans_model, |
const TransitionModel & | new_trans_model, | ||
const ContextDependencyInterface & | new_ctx_dep, | ||
const std::vector< int32 > & | old_alignment, | ||
int32 | subsample_factor, | ||
bool | repeat_frames, | ||
bool | reorder, | ||
const std::vector< int32 > * | phone_map, | ||
std::vector< int32 > * | new_alignment | ||
) |
ConvertAlignment converts an alignment that was created using one model, to another model.
Returns false if it could not be split to phones (e.g. because the alignment was partial), or because some other error happened, such as we couldn't convert the alignment because there were too few frames for the new topology.
old_trans_model | [in] The transition model that the original alignment used. |
new_trans_model | [in] The transition model that we want to use for the new alignment. |
new_ctx_dep | [in] The new tree |
old_alignment | [in] The alignment we want to convert |
subsample_factor | [in] The frame subsampling factor... normally 1, but might be > 1 if we're converting to a reduced-frame-rate system. |
repeat_frames | [in] Only relevant when subsample_factor != 1 If true, repeat frames of alignment by 'subsample_factor' after alignment conversion, to keep the alignment the same length as the input alignment. [note: we actually do this by interpolating 'subsample_factor' separately generated alignments, to keep the phone boundaries the same as the input where possible.] |
reorder | [in] True if you want the pdf-ids on the new alignment to be 'reordered'. (vs. the way they appear in the HmmTopology object) |
phone_map | [in] If non-NULL, map from old to new phones. |
new_alignment | [out] The converted alignment. |
Definition at line 1013 of file hmm-utils.cc.
References kaldi::ConvertAlignmentInternal(), rnnlm::i, and KALDI_ASSERT.
Referenced by main(), and kaldi::TestConvertAlignment().
bool ConvertPhnxToProns | ( | const std::vector< int32 > & | phnx, |
const std::vector< int32 > & | words, | ||
int32 | word_start_sym, | ||
int32 | word_end_sym, | ||
std::vector< std::vector< int32 > > * | prons | ||
) |
Definition at line 1161 of file hmm-utils.cc.
References rnnlm::i, and rnnlm::j.
Referenced by main(), and kaldi::TestConvertPhnxToProns().
bool GetPdfsForPhones | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | phones, | ||
std::vector< int32 > * | pdfs | ||
) |
Works out which pdfs might correspond to the given phones.
Will return true if these pdfs correspond *just* to these phones, false if these pdfs are also used by other phones.
trans_model | [in] Transition-model used to work out this information |
phones | [in] A sorted, uniq vector that represents a set of phones |
pdfs | [out] Will be set to a sorted, uniq list of pdf-ids that correspond to one of this set of phones. |
Definition at line 854 of file transition-model.cc.
References kaldi::IsSortedAndUniq(), KALDI_ASSERT, TransitionModel::NumTransitionStates(), kaldi::SortAndUniq(), TransitionModel::TransitionStateToForwardPdf(), TransitionModel::TransitionStateToPhone(), and TransitionModel::TransitionStateToSelfLoopPdf().
Referenced by main(), and TransitionModel::TransitionIdToPdfFast().
void GetPdfToPhonesMap | ( | const TransitionModel & | trans_model, |
std::vector< std::set< int32 > > * | pdf2phones | ||
) |
Definition at line 1292 of file hmm-utils.cc.
References rnnlm::i, TransitionModel::NumPdfs(), TransitionModel::NumTransitionIds(), TransitionModel::TransitionIdToPdf(), and TransitionModel::TransitionIdToPhone().
Referenced by main().
bool GetPhonesForPdfs | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | pdfs, | ||
std::vector< int32 > * | phones | ||
) |
Works out which phones might correspond to the given pdfs.
Similar to the above GetPdfsForPhones(, ,)
Definition at line 880 of file transition-model.cc.
References kaldi::IsSortedAndUniq(), KALDI_ASSERT, TransitionModel::NumTransitionStates(), kaldi::SortAndUniq(), TransitionModel::TransitionStateToForwardPdf(), TransitionModel::TransitionStateToPhone(), and TransitionModel::TransitionStateToSelfLoopPdf().
Referenced by kaldi::InitAmGmm(), and TransitionModel::TransitionIdToPdfFast().
void GetRandomAlignmentForPhone | ( | const ContextDependencyInterface & | ctx_dep, |
const TransitionModel & | trans_model, | ||
const std::vector< int32 > & | phone_window, | ||
std::vector< int32 > * | alignment | ||
) |
Definition at line 1207 of file hmm-utils.cc.
References ContextDependencyInterface::CentralPosition(), kaldi::GetHmmAsFsaSimple(), fst::GetInputSymbols(), TransitionModel::GetTopo(), rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_ERR, and HmmTopology::MinLength().
Referenced by kaldi::ConvertAlignmentForPhone().
bool SplitToPhones | ( | const TransitionModel & | trans_model, |
const std::vector< int32 > & | alignment, | ||
std::vector< std::vector< int32 > > * | split_alignment | ||
) |
SplitToPhones splits up the TransitionIds in "alignment" into their individual phones (one vector per instance of a phone).
At output, the sum of the sizes of the vectors in split_alignment will be the same as the corresponding sum for "alignment". The function returns true on success. If the alignment appears to be incomplete, e.g. not ending at the end-state of a phone, it will still break it up into phones but it will return false. For more serious errors it will die or throw an exception. This function works out by itself whether the graph was created with "reordering", and just does the right thing.
Definition at line 723 of file hmm-utils.cc.
References kaldi::IsReordered(), KALDI_ASSERT, and kaldi::SplitToPhonesInternal().
Referenced by kaldi::AccumulateTreeStats(), kaldi::CompactLatticeToWordProns(), kaldi::ConvertAlignmentInternal(), OnlineFasterDecoder::EndOfUtterance(), kaldi::IsPlausibleWord(), main(), kaldi::TestConvertAlignment(), and kaldi::TestSplitToPhones().
Definition at line 327 of file transition-model.h.
References KALDI_ASSERT.
Referenced by kaldi::AccumulateForUtterance(), DiscriminativeExampleSplitter::CollapseTransitionIds(), DiscriminativeSupervisionSplitter::CollapseTransitionIds(), kaldi::ComputeAmGmmFeatureDeriv(), DiscriminativeExampleSplitter::ComputeFrameInfo(), kaldi::ConvertPosteriorToPdfs(), kaldi::GetPdfToPhonesMap(), kaldi::GetPdfToTransitionIdTransducer(), kaldi::LatticeAcousticRescore(), kaldi::nnet1::LatticeAcousticRescore(), NnetDiscriminativeUpdater::LatticeComputations(), kaldi::LatticeForwardBackwardMpeVariants(), OnlineDecodableDiagGmmScaled::LogLikelihood(), DecodableDiagGmmScaledOnline::LogLikelihood(), DecodableNnet2Online::LogLikelihood(), DiscriminativeComputation::LookupNnetOutput(), main(), ComparePosteriorByPdfs::operator()(), kaldi::PosteriorToPdfMatrix(), kaldi::RescoreCompactLatticeInternal(), kaldi::nnet3::SetPriors(), and kaldi::nnet2::SetPriors().
Definition at line 334 of file transition-model.h.
References kaldi::GetPdfsForPhones(), kaldi::GetPhonesForPdfs(), and KALDI_PARANOID_ASSERT.
Referenced by DecodableAmDiagGmmRegtreeFmllr::LogLikelihood(), DecodableAmSgmm2::LogLikelihood(), DecodableMatrixScaledMapped::LogLikelihood(), DecodableAmNnet::LogLikelihood(), DecodableAmDiagGmmRegtreeMllr::LogLikelihood(), DecodableMatrixMapped::LogLikelihood(), DecodableAmSgmm2Scaled::LogLikelihood(), DecodableAmNnetParallel::LogLikelihood(), DecodableMatrixMappedOffset::LogLikelihood(), DecodableAmNnetSimpleLooped::LogLikelihood(), DecodableAmNnetSimple::LogLikelihood(), and DecodableAmNnetSimpleParallel::LogLikelihood().
|
static |
A constant used in the HmmTopology class as the pdf-class kNoPdf, which is used when a HMM-state is nonemitting (has no associated PDF).
Definition at line 86 of file hmm-topology.h.
Referenced by HmmTopology::Check(), TransitionModel::ComputeTuplesIsHmm(), TransitionModel::ComputeTuplesNotHmm(), kaldi::GetHmmAsFsa(), kaldi::GetHmmAsFsaSimple(), HmmTopology::Read(), kaldi::SplitToPhonesInternal(), and HmmTopology::Write().