43 #ifndef KALDI_FSTEXT_CONTEXT_FST_H_ 44 #define KALDI_FSTEXT_CONTEXT_FST_H_ 52 #include <unordered_map> 53 using std::unordered_map;
58 #include <fst/fstlib.h> 59 #include <fst/fst-decl.h> 71 const std::vector<std::vector<int32> > &ilabel_info);
75 std::vector<std::vector<int32> > *ilabel_info);
80 const SymbolTable &phones_symtab,
81 std::string separator,
82 std::string disambig_prefix);
111 VectorFst<StdArc> *ifst,
112 VectorFst<StdArc> *ofst,
113 std::vector<std::vector<int32> > *ilabels_out,
114 bool project_ifst =
false);
132 MutableFst<StdArc> *
fst);
175 const std::vector<int32>& phones,
176 const std::vector<int32>& disambig_syms,
178 int32 central_position);
181 virtual StateId
Start() {
return 0; }
183 virtual Weight
Final(StateId s);
186 virtual bool GetArc(StateId s, Label ilabel, Arc *arc);
206 StateId
FindState(
const std::vector<int32> &seq);
211 Label
FindLabel(
const std::vector<int32> &label_info);
226 const std::vector<int32> &phone_seq, Arc *arc);
244 std::vector<int32> *full_phone_sequence);
249 typedef unordered_map<std::vector<int32>,
StateId,
255 typedef unordered_map<std::vector<int32>,
Label,
340 #endif // KALDI_FSTEXT_CONTEXT_FST_H_ fst::StdArc::StateId StateId
const std::vector< std::vector< int32 > > & IlabelInfo() const
void WriteILabelInfo(std::ostream &os, bool binary, const vector< vector< int32 > > &info)
Utility function for writing ilabel-info vectors to disk.
VectorToStateMap state_map_
A hashing function-object for vectors.
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
void CreateDisambigArc(StateId s, Label ilabel, Arc *arc)
Create disambiguation-symbol self-loop arc; where 'ilabel' must correspond to a disambiguation symbol...
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...
Label subsequential_symbol_
Label FindLabel(const std::vector< int32 > &label_info)
Finds the label index corresponding to this context-window of phones (likely of width context_width_)...
std::vector< std::vector< int32 > > ilabel_info_
virtual Weight Final(StateId s)
InverseContextFst(Label subsequential_symbol, const std::vector< int32 > &phones, const std::vector< int32 > &disambig_syms, int32 context_width, int32 central_position)
Constructor.
bool IsDisambigSymbol(Label lab)
unordered_map< std::vector< int32 >, StateId, kaldi::VectorHasher< int32 > > VectorToStateMap
kaldi::ConstIntegerSet< Label > phone_syms_
void ReadILabelInfo(std::istream &is, bool binary, vector< vector< int32 > > *info)
Utility function for reading ilabel-info vectors from disk.
VectorToLabelMap ilabel_map_
virtual bool GetArc(StateId s, Label ilabel, Arc *arc)
Note: ilabel must not be epsilon.
class DeterministicOnDemandFst is an "FST-like" base-class.
unordered_map< std::vector< int32 >, Label, kaldi::VectorHasher< int32 > > VectorToLabelMap
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;...
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...
void SwapIlabelInfo(std::vector< std::vector< int32 > > *vec)
StateId FindState(const std::vector< int32 > &seq)
Returns the state-id corresponding to this vector of phones; creates the state it if necessary...
void AddSubsequentialLoop(StdArc::Label subseq_symbol, MutableFst< StdArc > *fst)
Modifies an FST so that it transuces the same paths, but the input side of the paths can all have the...
fst::StdArc::Weight Weight
kaldi::ConstIntegerSet< Label > disambig_syms_
void ComposeContext(const vector< int32 > &disambig_syms_in, int32 context_width, int32 central_position, VectorFst< StdArc > *ifst, VectorFst< StdArc > *ofst, vector< vector< int32 > > *ilabels_out, bool project_ifst)
Used in the command-line tool fstcomposecontext.
SymbolTable * CreateILabelInfoSymbolTable(const vector< vector< int32 > > &info, const SymbolTable &phones_symtab, std::string separator, std::string initial_disambig)
The following function is mainly of use for printing and debugging.
bool IsPhoneSymbol(Label lab)
std::vector< std::vector< int32 > > state_seqs_