28 int main(
int argc,
char *argv[]) {
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";
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...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
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...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
fst::VectorFst< CompactLatticeArc > CompactLattice
int main(int argc, char *argv[])
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void TopSortCompactLatticeIfNeeded(CompactLattice *clat)
Topologically sort the compact lattice if not already topologically sorted.
std::string GetOptArg(int param) const