#include <context-fst.h>
Public Types | |
typedef StdArc | Arc |
typedef StdArc::StateId | StateId |
typedef StdArc::Weight | Weight |
typedef StdArc::Label | Label |
Public Types inherited from DeterministicOnDemandFst< StdArc > | |
typedef StdArc ::StateId | StateId |
typedef StdArc ::Weight | Weight |
typedef StdArc ::Label | Label |
Public Member Functions | |
InverseContextFst (Label subsequential_symbol, const std::vector< int32 > &phones, const std::vector< int32 > &disambig_syms, int32 context_width, int32 central_position) | |
Constructor. More... | |
virtual StateId | Start () |
virtual Weight | Final (StateId s) |
virtual bool | GetArc (StateId s, Label ilabel, Arc *arc) |
Note: ilabel must not be epsilon. More... | |
~InverseContextFst () | |
const std::vector< std::vector< int32 > > & | IlabelInfo () const |
void | SwapIlabelInfo (std::vector< std::vector< int32 > > *vec) |
Public Member Functions inherited from DeterministicOnDemandFst< StdArc > | |
virtual Weight | Final (StateId s)=0 |
virtual bool | GetArc (StateId s, Label ilabel, StdArc *oarc)=0 |
Note: ilabel must not be epsilon. More... | |
virtual | ~DeterministicOnDemandFst () |
Private Types | |
typedef unordered_map< std::vector< int32 >, StateId, kaldi::VectorHasher< int32 > > | VectorToStateMap |
typedef unordered_map< std::vector< int32 >, Label, kaldi::VectorHasher< int32 > > | VectorToLabelMap |
Private Member Functions | |
StateId | FindState (const std::vector< int32 > &seq) |
Returns the state-id corresponding to this vector of phones; creates the state it if necessary. More... | |
Label | FindLabel (const std::vector< int32 > &label_info) |
Finds the label index corresponding to this context-window of phones (likely of width context_width_). More... | |
bool | IsDisambigSymbol (Label lab) |
bool | IsPhoneSymbol (Label lab) |
void | CreateDisambigArc (StateId s, Label ilabel, Arc *arc) |
Create disambiguation-symbol self-loop arc; where 'ilabel' must correspond to a disambiguation symbol. More... | |
void | CreatePhoneOrEpsArc (StateId src, StateId dst, Label ilabel, const std::vector< int32 > &phone_seq, Arc *arc) |
Creates an arc, this function is to be called only when 'ilabel' corresponds to a phone. More... | |
void | ShiftSequenceLeft (Label label, std::vector< int32 > *phone_seq) |
If phone_seq is nonempty then this function it left by one and appends 'label' to it, otherwise it does nothing. More... | |
void | GetFullPhoneSequence (const std::vector< int32 > &seq, Label label, std::vector< int32 > *full_phone_sequence) |
This utility function does something equivalent to the following 3 steps: *full_phone_sequence = seq; full_phone_sequence->append(label) Replace any values equal to 'subsequential_symbol_' in full_phone_sequence with zero (this is to avoid having to keep track of the value of 'subsequential_symbol_' outside of this program). More... | |
Private Attributes | |
int32 | context_width_ |
int32 | central_position_ |
kaldi::ConstIntegerSet< Label > | phone_syms_ |
kaldi::ConstIntegerSet< Label > | disambig_syms_ |
Label | subsequential_symbol_ |
int32 | pseudo_eps_symbol_ |
VectorToStateMap | state_map_ |
std::vector< std::vector< int32 > > | state_seqs_ |
VectorToLabelMap | ilabel_map_ |
std::vector< std::vector< int32 > > | ilabel_info_ |
Definition at line 152 of file context-fst.h.
Definition at line 154 of file context-fst.h.
typedef StdArc::Label Label |
Definition at line 157 of file context-fst.h.
typedef StdArc::StateId StateId |
Definition at line 155 of file context-fst.h.
|
private |
Definition at line 256 of file context-fst.h.
|
private |
Definition at line 250 of file context-fst.h.
typedef StdArc::Weight Weight |
Definition at line 156 of file context-fst.h.
InverseContextFst | ( | Label | subsequential_symbol, |
const std::vector< int32 > & | phones, | ||
const std::vector< int32 > & | disambig_syms, | ||
int32 | context_width, | ||
int32 | central_position | ||
) |
Constructor.
[in] | subsequential_symbol | The integer id of the 'subsequential symbol' (usually represented as '$') that terminates sequences on the output of C.fst (input of InverseContextFst). Search for "quential" in https://cs.nyu.edu/~mohri/pub/hbka.pdf. This may just be the first unused integer id. Must be nonzer. |
[in] | phones | List of integer ids of phones, as you would see in phones.txt |
[in] | disambig_syms | List of integer ids of disambiguation symbols, e.g. the ids of #0, #1, #2 in phones.txt |
[in] | context_width | Size of context window, e.g. 3 for triphone. |
[in] | central_position | Central position in context window (zero-based), e.g. 1 for triphone. See The ContextFst object for more details. |
Definition at line 27 of file context-fst.cc.
References InverseContextFst::central_position_, InverseContextFst::context_width_, ConstIntegerSet< I >::count(), InverseContextFst::disambig_syms_, ConstIntegerSet< I >::empty(), InverseContextFst::FindLabel(), InverseContextFst::FindState(), rnnlm::i, KALDI_ASSERT, KALDI_WARN, InverseContextFst::phone_syms_, and InverseContextFst::pseudo_eps_symbol_.
|
inline |
Definition at line 188 of file context-fst.h.
Create disambiguation-symbol self-loop arc; where 'ilabel' must correspond to a disambiguation symbol.
Called from CreateArc().
Definition at line 184 of file context-fst.cc.
References InverseContextFst::FindLabel().
Referenced by InverseContextFst::GetArc(), and InverseContextFst::IsPhoneSymbol().
|
inlineprivate |
Creates an arc, this function is to be called only when 'ilabel' corresponds to a phone.
Called from CreateArc(). The olabel may end be epsilon, instead of a phone-in-context, if the system has right context and we are very near the beginning of the phone sequence.
Definition at line 196 of file context-fst.cc.
References InverseContextFst::central_position_, InverseContextFst::FindLabel(), KALDI_PARANOID_ASSERT, InverseContextFst::pseudo_eps_symbol_, and InverseContextFst::subsequential_symbol_.
Referenced by InverseContextFst::GetArc(), and InverseContextFst::IsPhoneSymbol().
|
virtual |
Definition at line 109 of file context-fst.cc.
References InverseContextFst::central_position_, InverseContextFst::context_width_, KALDI_ASSERT, InverseContextFst::state_seqs_, and InverseContextFst::subsequential_symbol_.
Referenced by InverseContextFst::Start().
|
private |
Finds the label index corresponding to this context-window of phones (likely of width context_width_).
Inserts it into the ilabel_info_/ilabel_map_ tables if necessary.
Definition at line 231 of file context-fst.cc.
References InverseContextFst::ilabel_info_, and InverseContextFst::ilabel_map_.
Referenced by InverseContextFst::CreateDisambigArc(), InverseContextFst::CreatePhoneOrEpsArc(), InverseContextFst::InverseContextFst(), and InverseContextFst::SwapIlabelInfo().
|
private |
Returns the state-id corresponding to this vector of phones; creates the state it if necessary.
Requires seq.size() == context_width_ - 1.
Definition at line 216 of file context-fst.cc.
References InverseContextFst::context_width_, KALDI_ASSERT, InverseContextFst::state_map_, and InverseContextFst::state_seqs_.
Referenced by InverseContextFst::GetArc(), InverseContextFst::InverseContextFst(), and InverseContextFst::SwapIlabelInfo().
Note: ilabel must not be epsilon.
Definition at line 129 of file context-fst.cc.
References InverseContextFst::central_position_, InverseContextFst::context_width_, InverseContextFst::CreateDisambigArc(), InverseContextFst::CreatePhoneOrEpsArc(), InverseContextFst::FindState(), InverseContextFst::GetFullPhoneSequence(), InverseContextFst::IsDisambigSymbol(), InverseContextFst::IsPhoneSymbol(), KALDI_ASSERT, KALDI_ERR, InverseContextFst::ShiftSequenceLeft(), InverseContextFst::state_seqs_, and InverseContextFst::subsequential_symbol_.
Referenced by InverseContextFst::Start().
|
inlineprivate |
This utility function does something equivalent to the following 3 steps: *full_phone_sequence = seq; full_phone_sequence->append(label) Replace any values equal to 'subsequential_symbol_' in full_phone_sequence with zero (this is to avoid having to keep track of the value of 'subsequential_symbol_' outside of this program).
This function assumes that seq.size() == context_width_ - 1, and also that 'subsequential_symbol_' does not appear in positions 0 through central_position_ of 'seq'.
Definition at line 93 of file context-fst.cc.
References InverseContextFst::central_position_, InverseContextFst::context_width_, rnnlm::i, and InverseContextFst::subsequential_symbol_.
Referenced by InverseContextFst::GetArc(), and InverseContextFst::IsPhoneSymbol().
|
inline |
Definition at line 194 of file context-fst.h.
References InverseContextFst::ilabel_info_.
Referenced by fst::TestContextFst().
Definition at line 213 of file context-fst.h.
References ConstIntegerSet< I >::count(), and InverseContextFst::disambig_syms_.
Referenced by InverseContextFst::GetArc().
Definition at line 215 of file context-fst.h.
References ConstIntegerSet< I >::count(), InverseContextFst::CreateDisambigArc(), InverseContextFst::CreatePhoneOrEpsArc(), InverseContextFst::GetFullPhoneSequence(), InverseContextFst::phone_syms_, and InverseContextFst::ShiftSequenceLeft().
Referenced by InverseContextFst::GetArc().
|
inlineprivate |
If phone_seq is nonempty then this function it left by one and appends 'label' to it, otherwise it does nothing.
We expect (but do not check) that phone_seq->size() == context_width_ - 1.
Definition at line 85 of file context-fst.cc.
Referenced by InverseContextFst::GetArc(), and InverseContextFst::IsPhoneSymbol().
|
inlinevirtual |
Implements DeterministicOnDemandFst< StdArc >.
Definition at line 181 of file context-fst.h.
References InverseContextFst::Final(), and InverseContextFst::GetArc().
|
inline |
Definition at line 200 of file context-fst.h.
References InverseContextFst::FindLabel(), InverseContextFst::FindState(), and InverseContextFst::ilabel_info_.
Referenced by fst::ComposeContext().
|
private |
Definition at line 271 of file context-fst.h.
Referenced by InverseContextFst::CreatePhoneOrEpsArc(), InverseContextFst::Final(), InverseContextFst::GetArc(), InverseContextFst::GetFullPhoneSequence(), and InverseContextFst::InverseContextFst().
|
private |
Definition at line 262 of file context-fst.h.
Referenced by InverseContextFst::Final(), InverseContextFst::FindState(), InverseContextFst::GetArc(), InverseContextFst::GetFullPhoneSequence(), and InverseContextFst::InverseContextFst().
|
private |
Definition at line 285 of file context-fst.h.
Referenced by InverseContextFst::InverseContextFst(), and InverseContextFst::IsDisambigSymbol().
|
private |
Definition at line 333 of file context-fst.h.
Referenced by InverseContextFst::FindLabel(), InverseContextFst::IlabelInfo(), and InverseContextFst::SwapIlabelInfo().
|
private |
Definition at line 325 of file context-fst.h.
Referenced by InverseContextFst::FindLabel().
|
private |
Definition at line 276 of file context-fst.h.
Referenced by InverseContextFst::InverseContextFst(), and InverseContextFst::IsPhoneSymbol().
|
private |
Definition at line 309 of file context-fst.h.
Referenced by InverseContextFst::CreatePhoneOrEpsArc(), and InverseContextFst::InverseContextFst().
|
private |
Definition at line 314 of file context-fst.h.
Referenced by InverseContextFst::FindState().
|
private |
Definition at line 318 of file context-fst.h.
Referenced by InverseContextFst::Final(), InverseContextFst::FindState(), and InverseContextFst::GetArc().
|
private |
Definition at line 292 of file context-fst.h.
Referenced by InverseContextFst::CreatePhoneOrEpsArc(), InverseContextFst::Final(), InverseContextFst::GetArc(), and InverseContextFst::GetFullPhoneSequence().