68     using namespace kaldi;
    90         "Composes on the left with a dynamically created context FST\n"    92         "Usage:  fstcomposecontext <ilabels-output-file>  [<in.fst> [<out.fst>] ]\n"    93         "E.g:  fstcomposecontext ilabels.sym < LG.fst > CLG.fst\n";
    98     std::string disambig_rxfilename,
   100     int32 context_width = 3, central_position = 1;
   101     int32 nonterm_phones_offset = -1;
   102     po.Register(
"binary", &binary,
   103                 "If true, output ilabels-output-file in binary format");
   104     po.Register(
"read-disambig-syms", &disambig_rxfilename,
   105                 "List of disambiguation symbols on input of in.fst");
   106     po.Register(
"write-disambig-syms", &disambig_wxfilename,
   107                 "List of disambiguation symbols on input of out.fst");
   108     po.Register(
"context-size", &context_width, 
"Size of phone context window");
   109     po.Register(
"central-position", ¢ral_position,
   110                 "Designated central position in context window");
   111     po.Register(
"nonterm-phones-offset",  &nonterm_phones_offset,
   112                 "The integer id of #nonterm_bos in your phones.txt, if present "   113                 "(only relevant for grammar-FST construction, see "   118     if (po.NumArgs() < 1 || po.NumArgs() > 3) {
   123     std::string ilabels_out_filename = po.GetArg(1),
   124         fst_in_filename = po.GetOptArg(2),
   125         fst_out_filename = po.GetOptArg(3);
   129     if ( (disambig_wxfilename != 
"") && (disambig_rxfilename == 
"") )
   130       KALDI_ERR << 
"fstcomposecontext: cannot specify --write-disambig-syms if "   131           "not specifying --read-disambig-syms\n";
   133     std::vector<int32> disambig_in;
   134     if (disambig_rxfilename != 
"")
   136         KALDI_ERR << 
"fstcomposecontext: Could not read disambiguation symbols from "   139     if (disambig_in.empty()) {
   140       KALDI_WARN << 
"Disambiguation symbols list is empty; this likely "   141                  << 
"indicates an error in data preparation.";
   144     std::vector<std::vector<int32> > ilabels;
   145     VectorFst<StdArc> composed_fst;
   148     if (nonterm_phones_offset < 0) {
   151                      fst, &composed_fst, &ilabels);
   154       if (context_width != 2 || central_position != 1) {
   155         KALDI_ERR << 
"Grammar-fst graph creation only supports models with left-"   156             "biphone context.  (--nonterm-phones-offset option was supplied).";
   159                                 *fst, &composed_fst, &ilabels);
   164     if (disambig_wxfilename != 
"") {
   165       std::vector<int32> disambig_out;
   166       for (
size_t i = 0; 
i < ilabels.size(); 
i++)
   167         if (ilabels[
i].size() == 1 && ilabels[
i][0] <= 0)
   168           disambig_out.push_back(static_cast<int32>(
i));
   170         std::cerr << 
"fstcomposecontext: Could not write disambiguation symbols to "   179   } 
catch(
const std::exception &e) {
   180     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void WriteILabelInfo(std::ostream &os, bool binary, const vector< vector< int32 > > &info)
Utility function for writing ilabel-info vectors to disk. 
 
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
 
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
 
void ComposeContextLeftBiphone(int32 nonterm_phones_offset, const vector< int32 > &disambig_syms_in, const VectorFst< StdArc > &ifst, VectorFst< StdArc > *ofst, std::vector< std::vector< int32 > > *ilabels)
This is a variant of the function ComposeContext() which is to be used with our "grammar FST" framewo...
 
void ComposeContext(const vector< int32 > &disambig_syms_in, int32 context_width, int32 central_position, VectorFst< StdArc > *ifst, VectorFst< StdArc > *ofst, vector< vector< int32 > > *ilabels_out, bool project_ifst)
Used in the command-line tool fstcomposecontext. 
 
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)
 
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)
 
bool WriteIntegerVectorSimple(const std::string &wxfilename, const std::vector< int32 > &list)
WriteToList attempts to write this list of integers, one per line, to the given file, in text format. 
 
std::string PrintableRxfilename(const std::string &rxfilename)
PrintableRxfilename turns the rxfilename into a more human-readable form for error reporting...
 
std::string PrintableWxfilename(const std::string &wxfilename)
PrintableWxfilename turns the wxfilename into a more human-readable form for error reporting...
 
bool ReadIntegerVectorSimple(const std::string &rxfilename, std::vector< int32 > *list)
ReadFromList attempts to read this list of integers, one per line, from the given file...