26 int main(
int argc,
char *argv[]) {
28 using namespace kaldi;
30 using fst::SymbolTable;
35 "Compute FST difference on lattices (remove sequences in first lattice\n" 36 " that appear in second lattice)\n" 37 "Useful for the denominator lattice for MCE.\n" 38 "Usage: lattice-difference [options] " 39 "lattice1-rspecifier lattice2-rspecifier lattice-wspecifier\n" 40 " e.g.: lattice-difference ark:den.lats ark:num.lats ark:den_mce.lats\n";
50 std::string lats1_rspecifier = po.
GetArg(1);
51 std::string lats2_rspecifier = po.
GetArg(2);
52 std::string lats_wspecifier = po.
GetArg(3);
59 int32 n_done = 0, n_no_lat = 0, n_only_transcription = 0;
61 for (; !compact_lattice_reader1.
Done(); compact_lattice_reader1.
Next()) {
62 std::string key = compact_lattice_reader1.
Key();
64 if (compact_lattice_reader2.
HasKey(key)) {
73 Difference(clat1, clat2, &clat_out);
74 if (clat_out.Start() == 0) {
75 compact_lattice_writer.
Write(key, clat_out);
80 <<
" because difference is empty.";
81 n_only_transcription++;
84 KALDI_WARN <<
"No lattice found for utterance " << key <<
" in " 90 KALDI_LOG <<
"Total " << n_done <<
" lattices written; " 91 << n_only_transcription
92 <<
" lattices had empty difference; " 93 << n_no_lat <<
" missing lattices in second archive ";
94 return (n_done != 0 ? 0 : 1);
95 }
catch(
const std::exception &e) {
96 std::cerr << e.what();
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
Allows random access to a collection of objects in 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...
const T & Value(const std::string &key)
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.
bool HasKey(const std::string &key)
fst::VectorFst< CompactLatticeArc > CompactLattice
int NumArgs() const
Number of positional parameters (c.f. argc-1).
void RemoveWeights(MutableFst< Arc > *ifst)
int main(int argc, char *argv[])