28 fst::VectorFst<fst::StdArc> *lex_fst,
29 const std::vector<int32> &disambig_syms,
31 trans_model_(trans_model), ctx_dep_(ctx_dep), lex_fst_(lex_fst),
32 disambig_syms_(disambig_syms), opts_(opts) {
40 if (std::binary_search(phone_syms.begin(), phone_syms.end(),
43 <<
" is also a phone.";
59 fst::OLabelCompare<fst::StdArc> olabel_comp;
65 const std::vector<int32> &transcript,
66 fst::VectorFst<fst::StdArc> *out_fst) {
68 VectorFst<StdArc> word_fst;
74 fst::VectorFst<fst::StdArc> *out_fst) {
79 VectorFst<StdArc> phone2word_fst;
95 VectorFst<StdArc> ctx2word_fst;
103 std::vector<int32> disambig_syms_h;
111 VectorFst<StdArc> &trans2word_fst = *out_fst;
119 if (!disambig_syms_h.empty()) {
131 std::vector<int32> disambig;
132 bool check_no_self_loops =
true;
146 const std::vector<std::vector<int32> > &transcripts,
147 std::vector<fst::VectorFst<fst::StdArc>*> *out_fsts) {
149 std::vector<const VectorFst<StdArc>* > word_fsts(transcripts.size());
150 for (
size_t i = 0;
i < transcripts.size();
i++) {
151 VectorFst<StdArc> *word_fst =
new VectorFst<StdArc>();
153 word_fsts[
i] = word_fst;
156 for (
size_t i = 0;
i < transcripts.size();
i++)
162 const std::vector<
const fst::VectorFst<fst::StdArc>* > &word_fsts,
163 std::vector<fst::VectorFst<fst::StdArc>* > *out_fsts) {
168 out_fsts->resize(word_fsts.size(), NULL);
169 if (word_fsts.empty())
return true;
180 for (
size_t i = 0;
i < word_fsts.size();
i++) {
181 VectorFst<StdArc> phone2word_fst;
186 "Perhaps you have words missing in your lexicon?");
188 VectorFst<StdArc> ctx2word_fst;
193 (*out_fsts)[
i] = ctx2word_fst.Copy();
200 std::vector<int32> disambig_syms_h;
207 for (
size_t i = 0;
i < out_fsts->size();
i++) {
208 VectorFst<StdArc> &ctx2word_fst = *((*out_fsts)[
i]);
209 VectorFst<StdArc> trans2word_fst;
214 if (!disambig_syms_h.empty()) {
223 std::vector<int32> disambig;
224 bool check_no_self_loops =
true;
234 *((*out_fsts)[
i]) = trans2word_fst;
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
virtual int32 ContextWidth() const
ContextWidth() returns the value N (e.g.
const ContextDependency & ctx_dep_
void TableCompose(const Fst< Arc > &ifst1, const Fst< Arc > &ifst2, MutableFst< Arc > *ofst, const TableComposeOptions &opts=TableComposeOptions())
const std::vector< int32 > & GetPhones() const
Returns a sorted, unique list of phones.
void RemoveEpsLocal(MutableFst< Arc > *fst)
RemoveEpsLocal remove some (but not necessarily all) epsilons in an FST, using an algorithm that is g...
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
void AddSelfLoops(const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, BaseFloat self_loop_scale, bool reorder, bool check_no_self_loops, fst::VectorFst< fst::StdArc > *fst)
For context, see AddSelfLoops().
fst::TableComposeCache< fst::Fst< fst::StdArc > > lex_cache_
BaseFloat self_loop_scale
void MinimizeEncoded(VectorFst< Arc > *fst, float delta=kDelta)
const TransitionModel & trans_model_
void SortAndUniq(std::vector< T > *vec)
Sorts and uniq's (removes duplicates) from a vector.
fst::VectorFst< fst::StdArc > * lex_fst_
void ComposeDeterministicOnDemandInverse(const Fst< Arc > &right, DeterministicOnDemandFst< Arc > *left, MutableFst< Arc > *fst_composed)
This function does '*fst_composed = Compose(Inverse(*fst2), fst1)' Note that the arguments are revers...
void DeterminizeStarInLog(VectorFst< StdArc > *fst, float delta, bool *debug_ptr, int max_states)
void MakeLinearAcceptor(const std::vector< I > &labels, MutableFst< Arc > *ofst)
Creates unweighted linear acceptor from symbol sequence.
int32 subsequential_symbol_
Configuration class for the GetHTransducer() function; see The HTransducerConfig configuration class ...
std::vector< int32 > disambig_syms_
BaseFloat transition_scale
bool CompileGraphFromText(const std::vector< int32 > &transcript, fst::VectorFst< fst::StdArc > *out_fst)
TrainingGraphCompiler(const TransitionModel &trans_model, const ContextDependency &ctx_dep, fst::VectorFst< fst::StdArc > *lex_fst, const std::vector< int32 > &disambig_syms, const TrainingGraphCompilerOptions &opts)
virtual int32 CentralPosition() const
Central position P of the phone context, in 0-based numbering, e.g.
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...
bool CompileGraphsFromText(const std::vector< std::vector< int32 > > &word_grammar, std::vector< fst::VectorFst< fst::StdArc > *> *out_fsts)
bool CompileGraph(const fst::VectorFst< fst::StdArc > &word_grammar, fst::VectorFst< fst::StdArc > *out_fst)
fst::VectorFst< fst::StdArc > * GetHTransducer(const std::vector< std::vector< int32 > > &ilabel_info, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, const HTransducerConfig &config, std::vector< int32 > *disambig_syms_left)
Returns the H tranducer; result owned by caller.
BaseFloat transition_scale
Transition log-prob scale, see Scaling of transition and acoustic probabilities.
TrainingGraphCompilerOptions opts_
#define KALDI_ASSERT(cond)
bool CompileGraphs(const std::vector< const fst::VectorFst< fst::StdArc > *> &word_fsts, std::vector< fst::VectorFst< fst::StdArc > *> *out_fsts)
bool IsSortedAndUniq(const std::vector< T > &vec)
Returns true if the vector is sorted and contains each element only once.
void RemoveSomeInputSymbols(const std::vector< I > &to_remove, MutableFst< Arc > *fst)
RemoveSomeInputSymbols removes any symbol that appears in "to_remove", from the input side of the FST...