35 "Build regression class tree.\n" 36 "Usage: gmm-make-regtree [options] <model-file> <regtree-out>\n" 37 "E.g.: gmm-make-regtree --silphones=1:2:3 --state-occs=1.occs 1.mdl 1.regtree\n" 38 " [Note: state-occs come from --write-occs option of gmm-est]\n";
40 std::string occs_in_filename;
41 std::string sil_phones_str;
42 bool binary_write =
true;
45 po.Register(
"state-occs", &occs_in_filename,
"File containing state occupancies (use --write-occs in gmm-est)");
46 po.Register(
"sil-phones", &sil_phones_str,
"Colon-separated list of integer ids of silence phones, e.g. 1:2:3; if used, create top-level speech/sil split (only one reg-class for silence).");
47 po.Register(
"binary", &binary_write,
"Write output in binary mode");
48 po.Register(
"max-leaves", &max_leaves,
"Maximum number of leaves in regression tree.");
51 if (po.NumArgs() != 2) {
56 std::string model_in_filename = po.GetArg(1),
57 tree_out_filename = po.GetArg(2);
64 trans_model.
Read(ki.Stream(), binary_read);
65 am_gmm.
Read(ki.Stream(), binary_read);
69 if (occs_in_filename !=
"") {
72 state_occs.
Read(ki.Stream(), binary_read);
74 KALDI_LOG <<
"--state-occs option not provided so using constant occupancies.";
79 std::vector<int32> sil_pdfs;
80 if (sil_phones_str !=
"") {
81 std::vector<int32> sil_phones;
83 KALDI_ERR <<
"invalid sil-phones option " << sil_phones_str;
84 std::sort(sil_phones.begin(), sil_phones.end());
87 KALDI_WARN <<
"Pdfs associated with silence phones are not only " 88 "associated with silence phones: your speech-silence split " 89 "may not be meaningful.";
93 regtree.
BuildTree(state_occs, sil_pdfs, am_gmm, max_leaves);
97 regtree.
Write(ko.Stream(), binary_write);
100 KALDI_LOG <<
"Written regression tree to " << tree_out_filename;
101 }
catch(
const std::exception &e) {
102 std::cerr << e.what() <<
'\n';
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g.
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
void Write(std::ostream &out, bool binary) const
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
void BuildTree(const Vector< BaseFloat > &state_occs, const std::vector< int32 > &sil_indices, const AmDiagGmm &am, int32 max_clusters)
Top-down clustering of the Gaussians in a model based on their means.
A regression tree is a clustering of Gaussian densities in an acoustic model, such that the group of ...
void Read(std::istream &is, bool binary)
A class representing a vector.
void Set(Real f)
Set all members of a vector to a specified value.
bool GetPdfsForPhones(const TransitionModel &trans_model, const std::vector< int32 > &phones, std::vector< int32 > *pdfs)
Works out which pdfs might correspond to the given phones.
void Read(std::istream &in_stream, bool binary)
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams.