31 using namespace kaldi;
33 using fst::SymbolTable;
38 "Make H transducer from transition-ids to context-dependent phones, \n" 39 " without self-loops [use add-self-loops to add them]\n" 40 "Usage: make-h-transducer <ilabel-info-file> <tree-file> <transition-gmm/acoustic-model> [<H-fst-out>]\n" 42 " make-h-transducer ilabel_info 1.tree 1.mdl > H.fst\n";
46 std::string disambig_out_filename;
48 po.Register(
"disambig-syms-out", &disambig_out_filename,
"List of disambiguation symbols on input of H [to be output from this program]");
52 if (po.NumArgs() < 3 || po.NumArgs() > 4) {
57 std::string ilabel_info_filename = po.GetArg(1);
58 std::string tree_filename = po.GetArg(2);
59 std::string model_filename = po.GetArg(3);
60 std::string fst_out_filename;
61 if (po.NumArgs() >= 4) fst_out_filename = po.GetArg(4);
62 if (fst_out_filename ==
"-") fst_out_filename =
"";
64 std::vector<std::vector<int32> > ilabel_info;
67 Input ki(ilabel_info_filename, &binary_in);
77 std::vector<int32> disambig_syms_out;
86 if (fst_out_filename ==
"")
87 _setmode(_fileno(stdout), _O_BINARY);
90 if (disambig_out_filename !=
"") {
91 if (disambig_out_filename ==
"-")
92 disambig_out_filename =
"";
94 KALDI_ERR <<
"Could not write disambiguation symbols to " 95 << (disambig_out_filename ==
"" ?
96 "standard output" : disambig_out_filename);
99 if (! H->Write(fst_out_filename) )
100 KALDI_ERR <<
"make-h-transducer: error writing FST to " 101 << (fst_out_filename ==
"" ?
102 "standard output" : fst_out_filename);
106 }
catch(
const std::exception &e) {
107 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Register(OptionsItf *opts)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
void ReadILabelInfo(std::istream &is, bool binary, vector< vector< int32 > > *info)
Utility function for reading ilabel-info vectors from disk.
Configuration class for the GetHTransducer() function; see The HTransducerConfig configuration class ...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
fst::VectorFst< fst::StdArc > * GetHTransducer(const std::vector< std::vector< int32 > > &ilabel_info, const ContextDependencyInterface &ctx_dep, const TransitionModel &trans_model, const HTransducerConfig &config, std::vector< int32 > *disambig_syms_left)
Returns the H tranducer; result owned by caller.
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.