29 using namespace kaldi;
34 "Convert lattices so that the arcs in the CompactLattice format correspond with\n" 35 "phones. The output symbols are still words, unless you specify --replace-output-symbols=true\n" 36 "Usage: lattice-align-phones [options] <model> <lattice-rspecifier> <lattice-wspecifier>\n" 37 " e.g.: lattice-align-phones final.mdl ark:1.lats ark:phone_aligned.lats\n" 38 "See also: lattice-to-phone-lattice, lattice-align-words, lattice-align-words-lexicon\n" 39 "Note: if you just want the phone alignment from a lattice, the easiest path is\n" 40 " lattice-1best | nbest-to-linear [keeping only alignment] | ali-to-phones\n" 41 "If you want the words and phones jointly (i.e. pronunciations of words, with word\n" 43 " lattice-1best | nbest-to-prons\n";
46 bool output_if_error =
true;
48 po.Register(
"output-error-lats", &output_if_error,
"Output lattices that aligned " 49 "with errors (e.g. due to force-out");
56 if (po.NumArgs() != 3) {
62 model_rxfilename = po.GetArg(1),
63 lats_rspecifier = po.GetArg(2),
64 lats_wspecifier = po.GetArg(3);
72 int32 num_done = 0, num_err = 0;
74 for (; !clat_reader.Done(); clat_reader.Next()) {
75 std::string key = clat_reader.Key();
84 KALDI_WARN <<
"Lattice for " << key <<
" did align correctly";
86 if (aligned_clat.Start() != fst::kNoStateId) {
87 KALDI_LOG <<
"Outputting partial lattice for " << key;
89 clat_writer.Write(key, aligned_clat);
93 if (aligned_clat.Start() == fst::kNoStateId) {
95 KALDI_WARN <<
"Lattice was empty for key " << key;
98 KALDI_VLOG(2) <<
"Aligned lattice for " << key;
100 clat_writer.Write(key, aligned_clat);
104 KALDI_LOG <<
"Successfully aligned " << num_done <<
" lattices; " 105 << num_err <<
" had errors.";
106 return (num_done > num_err ? 0 : 1);
109 }
catch(
const std::exception &e) {
110 std::cerr << e.what();
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...
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
fst::VectorFst< CompactLatticeArc > CompactLattice
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...
void TopSortCompactLatticeIfNeeded(CompactLattice *clat)
Topologically sort the compact lattice if not already topologically sorted.
void Register(OptionsItf *opts)