30 using namespace kaldi;
33 typedef kaldi::uint64 uint64;
36 "Reads kaldi archives with FSTs. Concatenates the fsts from all the rspecifiers.\n" 37 "The fsts to concatenate must have same key. The sequencing is given by the position of arguments.\n" 39 "Usage: fsts-concat [options] <fsts-rspecifier1> <fsts-rspecifier2> ... <fsts-wspecifier>\n" 40 " e.g.: fsts-concat scp:fsts1.scp scp:fsts2.scp ... ark:fsts_out.ark\n" 42 "see also: fstconcat (from the OpenFst toolkit)\n";
48 if (po.NumArgs() < 3) {
53 std::string fsts_rspecifier = po.GetArg(1),
54 fsts_wspecifier = po.GetArg(po.NumArgs());
57 std::vector<RandomAccessTableReader<VectorFstHolder>*> fst_readers;
60 for (int32
i = 2;
i < po.NumArgs();
i++)
62 const int32 num_fst_readers = fst_readers.size();
67 for (; !fst_reader.Done(); fst_reader.Next()) {
68 std::string key = fst_reader.Key();
71 bool skip_key =
false;
72 for (int32
i = 0;
i < num_fst_readers;
i++) {
73 if (!fst_readers[
i]->HasKey(key)) {
75 <<
" due to missing the fst in " << (
i+2) <<
"th <rspecifier> : " 76 <<
"'" << po.GetArg(
i+2) <<
"'";
86 VectorFst<StdArc> fst_out = fst_readers.back()->Value(key);
89 for (int32
i = num_fst_readers-2;
i >= 0;
i--) {
90 fst::Concat(fst_readers[
i]->Value(key), &fst_out);
93 fst::Concat(fst_reader.Value(), &fst_out);
96 fst_writer.Write(key, fst_out);
101 for (int32
i = 0;
i < num_fst_readers;
i++)
102 delete fst_readers[
i];
105 KALDI_LOG <<
"Produced " << n_done <<
" FSTs by concatenating " << po.NumArgs()-1
106 <<
" streams " <<
"(" << n_skipped <<
" keys skipped).";
107 return (n_done != 0 ? 0 : 1);
108 }
catch(
const std::exception &e) {
109 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
A templated class for writing objects to an archive or script file; see The Table concept...
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...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...