28 std::vector<int32> *best_sentence,
29 std::vector<int32> *second_best_sentence) {
43 std::vector<Lattice> lats;
47 if (num_paths != NULL) *num_paths =
n;
48 if (best_sentence != NULL) best_sentence->clear();
49 if (second_best_sentence != NULL) second_best_sentence->clear();
53 fst::GetLinearSymbolSequence<LatticeArc,int32>(lats[0], NULL,
57 fst::GetLinearSymbolSequence<LatticeArc,int32>(lats[1], NULL,
68 return std::numeric_limits<BaseFloat>::infinity();
72 BaseFloat ans = second_best_cost - best_cost;
73 if (!(ans >= -0.001 * (fabs(best_cost) + fabs(second_best_cost)))) {
76 KALDI_WARN <<
"Very negative difference." << ans;
87 std::vector<int32> *best_sentence,
88 std::vector<int32> *second_best_sentence) {
96 int32 safety_term = 4 + max_sentence_length;
97 determinize_opts.
max_arcs = max_sentence_length * 2 + safety_term;
100 double prune_beam = std::numeric_limits<double>::infinity();
107 fst::Invert(&inverse_lat);
112 best_sentence, second_best_sentence);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
BaseFloat SentenceLevelConfidence(const CompactLattice &clat, int32 *num_paths, std::vector< int32 > *best_sentence, std::vector< int32 > *second_best_sentence)
Caution: this function is not the only way to get confidences in Kaldi.
bool DeterminizeLatticePruned(const ExpandedFst< ArcTpl< Weight > > &ifst, double beam, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, IntType > > > *ofst, DeterminizeLatticePrunedOptions opts)
void NbestAsFsts(const Fst< Arc > &fst, size_t n, std::vector< VectorFst< Arc > > *fsts_out)
Takes the n-shortest-paths (using ShortestPath), but outputs the result as a vector of up to n fsts...
double ConvertToCost(const LatticeWeightTpl< Float > &w)
void ConvertLattice(const ExpandedFst< ArcTpl< Weight > > &ifst, MutableFst< ArcTpl< CompactLatticeWeightTpl< Weight, Int > > > *ofst, bool invert)
Convert lattice from a normal FST to a CompactLattice FST.
fst::VectorFst< LatticeArc > Lattice
fst::VectorFst< CompactLatticeArc > CompactLattice
#define KALDI_ASSERT(cond)
int32 LongestSentenceLength(const Lattice &lat)
This function returns the number of words in the longest sentence in a CompactLattice (i...