71 using namespace kaldi;
73 using namespace kaldi;
77 "Initialize GMM, with Gaussians initialized to mean and variance\n" 78 "of some provided example data (or to 0,1 if not provided: in that\n" 79 "case, provide --dim option)\n" 80 "Usage: gmm-init-model-flat [options] <tree-in> <topo-file> <model-out> [<features-rspecifier>]\n" 82 " gmm-init-model-flat tree topo 1.mdl ark:feats.scp\n";
88 po.Register(
"binary", &binary,
"Write output in binary mode");
89 po.Register(
"dim", &dim,
"Dimension of model (this matters only if not providing features).");
93 if (po.NumArgs() < 3 || po.NumArgs() > 4) {
99 tree_filename = po.GetArg(1),
100 topo_filename = po.GetArg(2),
101 model_out_filename = po.GetArg(3),
102 feats_rspecifier = po.GetOptArg(4);
111 if (po.NumArgs() == 4) {
115 dim = global_mean.
Dim();
117 global_inverse_var.
Resize(dim);
118 global_inverse_var.
Set(1.0);
122 int32 num_pdfs = ctx_dep.
NumPdfs();
129 inv_var.Row(0).CopyFromVec(global_inverse_var);
131 mu.Row(0).CopyFromVec(global_mean);
138 for (
int i = 0;
i < num_pdfs;
i++)
144 Output ko(model_out_filename, binary);
145 trans_model.Write(ko.Stream(), binary);
146 am_gmm.
Write(ko.Stream(), binary);
149 }
catch(
const std::exception &e) {
150 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void AddPdf(const DiagGmm &gmm)
Adds a GMM to the model, and increments the total number of PDFs.
void SetInvVarsAndMeans(const MatrixBase< Real > &invvars, const MatrixBase< Real > &means)
Use SetInvVarsAndMeans if updating both means and (inverse) variances.
A class for storing topology information for phones.
void Resize(int32 nMix, int32 dim)
Resizes arrays to this dim. Does not initialize data.
int32 ComputeGconsts()
Sets the gconsts.
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
virtual int32 NumPdfs() const
NumPdfs() returns the number of acoustic pdfs (they are numbered 0.. NumPdfs()-1).
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
MatrixIndexT Dim() const
Returns the dimension of the vector.
A class representing a vector.
void Set(Real f)
Set all members of a vector to a specified value.
void Write(std::ostream &out_stream, bool binary) const
Definition for Gaussian Mixture Model with diagonal covariances.
void SetWeights(const VectorBase< Real > &w)
Mutators for both float or double.
void GetFeatureMeanAndVariance(const std::string &feat_rspecifier, Vector< BaseFloat > *inv_var_out, Vector< BaseFloat > *mean_out)