44 const std::vector<int32> &
string = arc.weight.String();
46 string.begin(),
string.end());
129 input_state(input_state), comp_state(comp_state) {}
135 size_t operator() (
const Tuple &state)
const {
141 bool operator () (
const Tuple &state1,
const Tuple &state2)
const {
148 typedef unordered_map<Tuple, StateId, TupleHash, TupleEqual>
MapType;
151 MapType::iterator iter =
map_.find(tuple);
152 if (iter ==
map_.end()) {
153 StateId output_state =
lat_out_->AddState();
154 map_[tuple] = output_state;
156 queue_.push_back(std::make_pair(tuple, output_state));
170 std::vector<int32> empty_vec;
189 lat_out_->AddArc(output_state, lat_arc);
197 StateId output_state =
queue_.back().second;
214 lat_out_->AddArc(output_state, lat_arc);
227 for(fst::ArcIterator<CompactLattice> aiter(
lat_, tuple.input_state);
228 !aiter.Done(); aiter.Next()) {
230 Tuple next_tuple(tuple);
267 if (
lat_.Start() == fst::kNoStateId) {
268 KALDI_WARN <<
"Trying to word-align empty lattice.";
272 Tuple initial_tuple(
lat_.Start(), initial_comp_state);
290 std::vector<std::pair<Tuple, StateId> >
queue_;
307 for (
i = 0;
i < len;
i++) {
310 if (this_phone != phone && ! *error) {
314 KALDI_WARN <<
"Phone changed before final transition-id found " 315 "[broken lattice or mismatched model or wrong --reorder option?]";
320 if (
i == len)
return false;
324 if (i == len)
return false;
330 Label output_label = 0;
336 output_label = phone;
384 bool is_final = tmodel.
IsFinal(this_tid);
385 if (is_final) num_final++;
386 if (this_phone != phone && ! *error) {
387 KALDI_WARN <<
"Mismatch in phone: error in lattice or mismatched transition model?";
391 if (num_final != 1 && ! *error) {
392 KALDI_WARN <<
"Problem phone-aligning lattice: saw " << num_final
393 <<
" final-states in last phone in lattice (forced out?) " 394 <<
"Producing partial lattice.";
399 Label output_label = 0;
405 output_label = phone;
fst::StdArc::StateId StateId
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void ProcessQueueElement()
bool operator==(const ComputationState &other) const
CompactLattice * lat_out_
A hashing function-object for vectors.
static const LatticeWeightTpl One()
LatticeWeightTpl< FloatType > Plus(const LatticeWeightTpl< FloatType > &w1, const LatticeWeightTpl< FloatType > &w2)
fst::CompactLatticeWeightTpl< LatticeWeight, int32 > CompactLatticeWeight
bool OutputPhoneArc(const TransitionModel &tmodel, const PhoneAlignLatticeOptions &opts, CompactLatticeArc *arc_out, bool *error)
If it can output a whole phone, it will do so, will put it in arc_out, and return true; else it will ...
StateId GetStateForTuple(const Tuple &tuple, bool add_to_queue)
CompactLatticeArc::StateId StateId
ComputationState(const ComputationState &other)
const PhoneAlignLatticeOptions & opts_
bool OutputWordArc(const TransitionModel &tmodel, const PhoneAlignLatticeOptions &opts, CompactLatticeArc *arc_out, bool *error)
This will succeed (and output the arc) if we have >1 word in words_; the arc won't have any transitio...
std::vector< int32 > transition_ids_
LatticeWeight FinalWeight()
FinalWeight() will return "weight" if both transition_ids and word_labels are empty, otherwise it will return Weight::Zero().
LatticeWeightTpl< FloatType > Times(const LatticeWeightTpl< FloatType > &w1, const LatticeWeightTpl< FloatType > &w2)
unordered_map< Tuple, StateId, TupleHash, TupleEqual > MapType
static const CompactLatticeWeightTpl< WeightType, IntType > One()
void OutputArcForce(const TransitionModel &tmodel, const PhoneAlignLatticeOptions &opts, CompactLatticeArc *arc_out, bool *error)
This function may be called when you reach the end of the lattice and this structure hasn't voluntari...
ComputationState comp_state
void ProcessFinal(Tuple tuple, StateId output_state)
Arc::StateId CreateSuperFinal(MutableFst< Arc > *fst)
bool IsSelfLoop(int32 trans_id) const
static const LatticeWeightTpl Zero()
const TransitionModel & tmodel_
LatticePhoneAligner(const CompactLattice &lat, const TransitionModel &tmodel, const PhoneAlignLatticeOptions &opts, CompactLattice *lat_out)
CompactLatticeArc::Label Label
void RemoveEpsilonsFromLattice()
fst::VectorFst< CompactLatticeArc > CompactLattice
void Advance(const CompactLatticeArc &arc, const PhoneAlignLatticeOptions &opts, LatticeWeight *weight)
The state of the computation in which,.
std::vector< std::pair< Tuple, StateId > > queue_
bool replace_output_symbols
#define KALDI_ASSERT(cond)
static const CompactLatticeWeightTpl< WeightType, IntType > Zero()
fst::ArcTpl< CompactLatticeWeight > CompactLatticeArc
bool PhoneAlignLattice(const CompactLattice &lat, const TransitionModel &tmodel, const PhoneAlignLatticeOptions &opts, CompactLattice *lat_out)
Outputs a lattice in which the arcs correspond exactly to sequences of phones, so the boundaries betw...
bool IsFinal(int32 trans_id) const
int32 TransitionIdToPhone(int32 trans_id) const
Tuple(StateId input_state, ComputationState comp_state)
std::vector< int32 > word_labels_