21 #ifndef KALDI_HMM_TRANSITION_MODEL_H_ 22 #define KALDI_HMM_TRANSITION_MODEL_H_ 26 #include "fst/fst-decl.h" 95 bool share_for_pdfs =
false):
96 floor(floor), mincount(mincount), share_for_pdfs(share_for_pdfs) {}
99 opts->
Register(
"transition-floor", &floor,
100 "Floor for transition probabilities");
101 opts->
Register(
"transition-min-count", &mincount,
102 "Minimum count required to update transitions from a state");
103 opts->
Register(
"share-for-pdfs", &share_for_pdfs,
104 "If true, share all transition parameters where the states " 105 "have the same pdf.");
115 opts->
Register(
"transition-tau", &tau,
"Tau value for MAP estimation of transition " 117 opts->
Register(
"share-for-pdfs", &share_for_pdfs,
118 "If true, share all transition parameters where the states " 119 "have the same pdf.");
136 void Read(std::istream &is,
bool binary);
137 void Write(std::ostream &os,
bool binary)
const;
148 int32 TransitionIdToTransitionState(
int32 trans_id)
const;
149 int32 TransitionIdToTransitionIndex(
int32 trans_id)
const;
150 int32 TransitionStateToPhone(
int32 trans_state)
const;
151 int32 TransitionStateToHmmState(
int32 trans_state)
const;
152 int32 TransitionStateToForwardPdfClass(
int32 trans_state)
const;
153 int32 TransitionStateToSelfLoopPdfClass(
int32 trans_state)
const;
154 int32 TransitionStateToForwardPdf(
int32 trans_state)
const;
155 int32 TransitionStateToSelfLoopPdf(
int32 trans_state)
const;
159 inline int32 TransitionIdToPdf(
int32 trans_id)
const;
162 inline int32 TransitionIdToPdfFast(
int32 trans_id)
const;
164 int32 TransitionIdToPhone(
int32 trans_id)
const;
165 int32 TransitionIdToPdfClass(
int32 trans_id)
const;
166 int32 TransitionIdToHmmState(
int32 trans_id)
const;
170 bool IsFinal(
int32 trans_id)
const;
172 bool IsSelfLoop(
int32 trans_id)
const;
181 int32 NumTransitionIndices(
int32 trans_state)
const;
196 int32 NumPhones()
const;
199 const std::vector<int32> &
GetPhones()
const {
return topo_.GetPhones(); }
213 BaseFloat GetTransitionLogProbIgnoringSelfLoops(
int32 trans_id)
const;
236 void Print(std::ostream &os,
237 const std::vector<std::string> &phone_names,
245 (*stats)(trans_id) += prob;
264 void ComputeDerived();
265 void ComputeDerivedOfProbs();
267 void InitializeProbs();
278 phone(phone), hmm_state(hmm_state), forward_pdf(forward_pdf), self_loop_pdf(self_loop_pdf) { }
280 if (phone < other.
phone)
return true;
281 else if (phone > other.
phone)
return false;
282 else if (hmm_state < other.
hmm_state)
return true;
283 else if (hmm_state > other.
hmm_state)
return false;
284 else if (forward_pdf < other.
forward_pdf)
return true;
285 else if (forward_pdf > other.
forward_pdf)
return false;
329 static_cast<size_t>(trans_id) < id2pdf_id_.size() &&
330 "Likely graph/model mismatch (graph built from wrong model?)");
331 return id2pdf_id_[trans_id];
342 static_cast<size_t>(trans_id) < id2pdf_id_.size() &&
343 "Likely graph/model mismatch (graph built from wrong model?)");
344 return id2pdf_id_[trans_id];
357 const std::vector<int32> &phones,
358 std::vector<int32> *pdfs);
363 const std::vector<int32> &pdfs,
364 std::vector<int32> *phones);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
std::vector< Tuple > tuples_
Tuples indexed by transition state minus one; the tuples are in sorted order which allows us to do th...
A class for storing topology information for phones.
std::vector< int32 > id2pdf_id_
const std::vector< int32 > & GetPhones() const
Returns a sorted, unique list of phones.
int32 TransitionIdToPdfFast(int32 trans_id) const
int32 num_pdfs_
This is actually one plus the highest-numbered pdf we ever got back from the tree (but the tree numbe...
Vector< BaseFloat > log_probs_
For each transition-id, the corresponding log-prob. Indexed by transition-id.
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
#define KALDI_DISALLOW_COPY_AND_ASSIGN(type)
int32 TransitionIdToPdf(int32 trans_id) const
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
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.
void InitStats(Vector< double > *stats) const
void Register(OptionsItf *opts)
MleTransitionUpdateConfig(BaseFloat floor=0.01, BaseFloat mincount=5.0, bool share_for_pdfs=false)
int32 NumTransitionIds() const
Returns the total number of transition-ids (note, these are one-based).
void Accumulate(BaseFloat prob, int32 trans_id, Vector< double > *stats) const
std::vector< int32 > id2state_
For each transition-id, the corresponding transition state (indexed by transition-id).
const HmmTopology & GetTopo() const
return reference to HMM-topology object.
TransitionModel()
Constructor that takes no arguments: typically used prior to calling Read.
#define KALDI_PARANOID_ASSERT(cond)
Tuple(int32 phone, int32 hmm_state, int32 forward_pdf, int32 self_loop_pdf)
std::vector< int32 > state2id_
Gives the first transition_id of each transition-state; indexed by the transition-state.
bool operator<(const Int32Pair &a, const Int32Pair &b)
context-dep-itf.h provides a link between the tree-building code in ../tree/, and the FST code in ...
MapTransitionUpdateConfig()
#define KALDI_ASSERT(cond)
bool operator==(const LatticeWeightTpl< FloatType > &wa, const LatticeWeightTpl< FloatType > &wb)
void Print(const Fst< Arc > &fst, std::string message)
void Register(OptionsItf *opts)
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.
int32 NumTransitionStates() const
Returns the total number of transition-states (note, these are one-based).
Vector< BaseFloat > non_self_loop_log_probs_
For each transition-state, the log of (1 - self-loop-prob).