32 using namespace kaldi;
35 "Accumulate MLLT (global STC) statistics: this version is for where there is\n" 36 "one global GMM (e.g. a UBM)\n" 37 "Usage: gmm-acc-mllt-global [options] <gmm-in> <feature-rspecifier> <stats-out>\n" 39 " gmm-acc-mllt-global 1.dubm scp:feats.scp 1.macc\n";
44 std::string gselect_rspecifier;
45 po.Register(
"binary", &binary,
"Write output in binary mode");
46 po.Register(
"rand-prune", &rand_prune,
"Randomized pruning parameter to speed up " 47 "accumulation (larger -> more pruning. May exceed one).");
48 po.Register(
"gselect", &gselect_rspecifier,
"Rspecifier for Gaussian selection " 52 if (po.NumArgs() != 3) {
57 std::string gmm_filename = po.GetArg(1),
58 feature_rspecifier = po.GetArg(2),
59 accs_wxfilename = po.GetArg(3);
61 using namespace kaldi;
69 double tot_like = 0.0;
75 int32 num_done = 0, num_err = 0;
76 for (; !feature_reader.Done(); feature_reader.Next()) {
77 std::string utt = feature_reader.Key();
81 BaseFloat tot_like_this_file = 0.0, tot_weight = 0.0;
83 if (gselect_rspecifier ==
"") {
85 tot_like_this_file += mllt_accs.AccumulateFromGmm(gmm, mat.
Row(
i), 1.0);
89 if (!gselect_reader.HasKey(utt)) {
90 KALDI_WARN <<
"No gselect information for utterance " << utt;
94 const std::vector<std::vector<int32> > &gselect= gselect_reader.Value(utt);
95 if (static_cast<int32>(gselect.size()) != mat.
NumRows()) {
96 KALDI_WARN <<
"Gselect information has wrong size for utterance " 97 << utt <<
", " << gselect.size() <<
" vs. " 104 tot_like_this_file += mllt_accs.AccumulateFromGmmPreselect(
105 gmm, gselect[
i], mat.
Row(i), 1.0);
109 KALDI_LOG <<
"Average like for this file is " 110 << (tot_like_this_file/tot_weight) <<
" over " 111 << tot_weight <<
" frames.";
112 tot_like += tot_like_this_file;
114 if (num_done % 10 == 0)
115 KALDI_LOG <<
"Avg like per frame so far is " 119 KALDI_LOG <<
"Done " << num_done <<
" files. ";
121 KALDI_LOG <<
"Overall avg like per frame (Gaussian only) = " 122 << (tot_like/tot_t) <<
" over " << tot_t <<
" frames.";
126 return (num_done != 0 ? 0 : 1);
127 }
catch(
const std::exception &e) {
128 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
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...
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition for Gaussian Mixture Model with diagonal covariances.
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
A class for estimating Maximum Likelihood Linear Transform, also known as global Semi-tied Covariance...