30 using namespace kaldi;
32 typedef kaldi::int64 int64;
39 "Compute the lattice depths in terms of the average number of arcs that\n" 40 "cross a frame. See also lattice-depth-per-frame\n" 41 "Usage: lattice-depth <lattice-rspecifier> [<depth-wspecifier>]\n" 42 "E.g.: lattice-depth ark:- ark,t:-\n";
48 if (po.NumArgs() < 1 || po.NumArgs() > 2) {
53 std::string lats_rspecifier = po.GetArg(1);
56 std::string depth_wspecifier = po.GetOptArg(2);
60 double sum_depth = 0.0, total_t = 0.0;
61 for (; !clat_reader.Done(); clat_reader.Next()) {
63 std::string key = clat_reader.Key();
70 if (depth_wspecifier !=
"")
71 lats_depth_writer.Write(key, depth);
73 sum_depth += depth * t;
77 KALDI_LOG <<
"Done " << num_done <<
" lattices.";
79 KALDI_LOG <<
"Overall density is " << (sum_depth / total_t) <<
" over " 80 << total_t <<
" frames.";
81 if (num_done != 0)
return 0;
83 }
catch (
const std::exception &e) {
84 std::cerr << e.what();
fst::StdArc::StateId StateId
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
A templated class for writing objects to an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
BaseFloat CompactLatticeDepth(const CompactLattice &clat, int32 *num_frames)
Returns the depth of the lattice, defined as the average number of arcs crossing any given frame...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< CompactLatticeArc > CompactLattice
void TopSortCompactLatticeIfNeeded(CompactLattice *clat)
Topologically sort the compact lattice if not already topologically sorted.