A class for storing topology information for phones. More...
#include <hmm-topology.h>
Classes | |
struct | HmmState |
A structure defined inside HmmTopology to represent a HMM state. More... | |
Public Types | |
typedef std::vector< HmmState > | TopologyEntry |
TopologyEntry is a typedef that represents the topology of a single (prototype) state. More... | |
Public Member Functions | |
void | Read (std::istream &is, bool binary) |
void | Write (std::ostream &os, bool binary) const |
void | Check () |
bool | IsHmm () const |
Returns true if this HmmTopology is really 'hmm-like', i.e. More... | |
const TopologyEntry & | TopologyForPhone (int32 phone) const |
Returns the topology entry (i.e. More... | |
int32 | NumPdfClasses (int32 phone) const |
Returns the number of pdf-classes for this phone; throws exception if phone not covered by this topology. More... | |
const std::vector< int32 > & | GetPhones () const |
Returns a reference to a sorted, unique list of phones covered by the topology (these phones will be positive integers, and usually contiguous and starting from one but the toolkit doesn't assume they are contiguous). More... | |
void | GetPhoneToNumPdfClasses (std::vector< int32 > *phone2num_pdf_classes) const |
Outputs a vector of int32, indexed by phone, that gives the number of Pdf-classes pdf-classes for the phones; this is used by tree-building code such as BuildTree(). More... | |
int32 | MinLength (int32 phone) const |
HmmTopology () | |
bool | operator== (const HmmTopology &other) const |
Private Attributes | |
std::vector< int32 > | phones_ |
std::vector< int32 > | phone2idx_ |
std::vector< TopologyEntry > | entries_ |
A class for storing topology information for phones.
See HMM topology and transition modeling for context. This object is sometimes accessed in a file by itself, but more often as a class member of the Transition class (this is for convenience to reduce the number of files programs have to access).
Definition at line 93 of file hmm-topology.h.
typedef std::vector<HmmState> TopologyEntry |
TopologyEntry is a typedef that represents the topology of a single (prototype) state.
Definition at line 133 of file hmm-topology.h.
|
inline |
Definition at line 174 of file hmm-topology.h.
void Check | ( | ) |
Definition at line 232 of file hmm-topology.cc.
References HmmTopology::entries_, rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_ERR, KALDI_WARN, kaldi::kNoPdf, HmmTopology::phone2idx_, HmmTopology::phones_, and kaldi::SortAndUniq().
Referenced by HmmTopology::Read().
|
inline |
Returns a reference to a sorted, unique list of phones covered by the topology (these phones will be positive integers, and usually contiguous and starting from one but the toolkit doesn't assume they are contiguous).
Definition at line 163 of file hmm-topology.h.
References HmmTopology::GetPhoneToNumPdfClasses(), HmmTopology::MinLength(), and HmmTopology::phones_.
Referenced by TransitionModel::ComputeTuplesIsHmm(), TransitionModel::ComputeTuplesNotHmm(), HmmTopology::IsHmm(), TransitionModel::IsHmm(), main(), and kaldi::ProcessTopo().
void GetPhoneToNumPdfClasses | ( | std::vector< int32 > * | phone2num_pdf_classes | ) | const |
Outputs a vector of int32, indexed by phone, that gives the number of Pdf-classes pdf-classes for the phones; this is used by tree-building code such as BuildTree().
Definition at line 31 of file hmm-topology.cc.
References rnnlm::i, KALDI_ASSERT, HmmTopology::NumPdfClasses(), and HmmTopology::phones_.
Referenced by HmmTopology::GetPhones().
bool IsHmm | ( | ) | const |
Returns true if this HmmTopology is really 'hmm-like', i.e.
the pdf-class on the self-loops and forward transitions of all states are identical. [note: in HMMs, the densities are associated with the states.] We have extended this to support 'non-hmm-like' topologies (where those pdf-classes are different), in order to make for more compact decoding graphs in our so-called 'chain models' (AKA lattice-free MMI), where we use 1-state topologies that have different pdf-classes for the self-loop and the forward transition. Note that we always use the 'reorder=true' option so the 'forward transition' actually comes before the self-loop.
Definition at line 316 of file hmm-topology.cc.
References HmmTopology::GetPhones(), rnnlm::i, rnnlm::j, KALDI_ASSERT, and HmmTopology::TopologyForPhone().
Referenced by HmmTopology::Write().
Definition at line 350 of file hmm-topology.cc.
References KALDI_ASSERT, HmmTopology::TopologyForPhone(), and HmmTopology::HmmState::transitions.
Referenced by kaldi::ComputeNewPhoneLengths(), HmmTopology::GetPhones(), kaldi::GetRandomAlignmentForPhone(), and kaldi::TestHmmTopology().
Returns the number of pdf-classes for this phone; throws exception if phone not covered by this topology.
Definition at line 339 of file hmm-topology.cc.
References rnnlm::i, and HmmTopology::TopologyForPhone().
Referenced by TransitionModel::ComputeTuplesIsHmm(), kaldi::GetHmmAsFsa(), kaldi::GetIlabelMapping(), HmmTopology::GetPhoneToNumPdfClasses(), main(), and kaldi::ProcessTopo().
|
inline |
Definition at line 176 of file hmm-topology.h.
References HmmTopology::entries_, HmmTopology::phone2idx_, and HmmTopology::phones_.
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 39 of file hmm-topology.cc.
References HmmTopology::Check(), kaldi::ConvertStringToInteger(), HmmTopology::entries_, kaldi::ExpectToken(), rnnlm::i, kaldi::IsSortedAndUniq(), rnnlm::j, KALDI_ASSERT, KALDI_ERR, kaldi::kNoPdf, HmmTopology::phone2idx_, HmmTopology::phones_, kaldi::ReadBasicType(), kaldi::ReadIntegerVector(), and kaldi::ReadToken().
Referenced by kaldi::GenRandTopology(), kaldi::GetDefaultTopology(), main(), TransitionModel::Read(), and kaldi::TestHmmTopology().
const HmmTopology::TopologyEntry & TopologyForPhone | ( | int32 | phone | ) | const |
Returns the topology entry (i.e.
vector of HmmState) for this phone; will throw exception if phone not covered by the topology.
Definition at line 332 of file hmm-topology.cc.
References HmmTopology::entries_, KALDI_ERR, and HmmTopology::phone2idx_.
Referenced by TransitionModel::ComputeDerived(), TransitionModel::ComputeTuplesIsHmm(), TransitionModel::ComputeTuplesNotHmm(), kaldi::ConvertAlignmentForPhone(), kaldi::GeneratePathThroughHmm(), kaldi::GenerateRandomAlignment(), kaldi::GetHmmAsFsa(), kaldi::GetHmmAsFsaSimple(), TransitionModel::InitializeProbs(), TransitionModel::IsFinal(), HmmTopology::IsHmm(), TransitionModel::IsHmm(), TransitionModel::IsSelfLoop(), HmmTopology::MinLength(), HmmTopology::NumPdfClasses(), TransitionModel::Print(), TransitionModel::SelfLoopOf(), kaldi::SplitToPhonesInternal(), TransitionModel::TransitionIdToPdfClass(), TransitionModel::TransitionStateToForwardPdfClass(), and TransitionModel::TransitionStateToSelfLoopPdfClass().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 165 of file hmm-topology.cc.
References HmmTopology::entries_, rnnlm::i, HmmTopology::IsHmm(), rnnlm::j, KALDI_ASSERT, kaldi::kNoPdf, HmmTopology::phone2idx_, HmmTopology::phones_, kaldi::WriteBasicType(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().
Referenced by kaldi::TestHmmTopology(), and TransitionModel::Write().
|
private |
Definition at line 184 of file hmm-topology.h.
Referenced by HmmTopology::Check(), HmmTopology::operator==(), HmmTopology::Read(), HmmTopology::TopologyForPhone(), and HmmTopology::Write().
|
private |
Definition at line 183 of file hmm-topology.h.
Referenced by HmmTopology::Check(), HmmTopology::operator==(), HmmTopology::Read(), HmmTopology::TopologyForPhone(), and HmmTopology::Write().
|
private |
Definition at line 182 of file hmm-topology.h.
Referenced by HmmTopology::Check(), HmmTopology::GetPhones(), HmmTopology::GetPhoneToNumPdfClasses(), HmmTopology::operator==(), HmmTopology::Read(), and HmmTopology::Write().