39 using namespace kaldi;
41 "Estimate global fMLLR transforms, either per utterance or for the supplied\n" 42 "set of speakers (spk2utt option). This version is for when you have a single\n" 43 "global GMM, e.g. a UBM. Writes to a table of matrices.\n" 44 "Usage: gmm-est-fmllr-global [options] <gmm-in> <feature-rspecifier> " 45 "<transform-wspecifier>\n" 46 "e.g.: gmm-est-fmllr-global 1.ubm scp:feats.scp ark:trans.1\n";
50 string spk2utt_rspecifier;
51 string gselect_rspecifier;
52 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 53 "utterance-list map");
54 po.Register(
"gselect", &gselect_rspecifier,
"rspecifier for " 55 "Gaussian-selection information");
60 if (po.NumArgs() != 3) {
65 string gmm_rxfilename = po.GetArg(1),
66 feature_rspecifier = po.GetArg(2),
67 trans_wspecifier = po.GetArg(3);
72 double tot_impr = 0.0, tot_t = 0.0;
77 int32 num_done = 0, num_err = 0;
78 if (spk2utt_rspecifier !=
"") {
82 for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
84 string spk = spk2utt_reader.Key();
85 const vector<string> &uttlist = spk2utt_reader.Value();
86 for (
size_t i = 0;
i < uttlist.size();
i++) {
87 std::string utt = uttlist[
i];
88 if (!feature_reader.HasKey(utt)) {
89 KALDI_WARN <<
"Did not find features for utterance " << utt;
95 if (gselect_rspecifier ==
"") {
97 spk_stats.AccumulateForGmm(gmm, feats.
Row(
i), 1.0);
99 if (!gselect_reader.HasKey(utt) ||
100 gselect_reader.Value(utt).size() != feats.
NumRows()) {
101 KALDI_LOG <<
"No gselect information for utterance " << utt
102 <<
" (or wrong size)";
106 const std::vector<std::vector<int32> > &gselect =
107 gselect_reader.Value(utt);
109 spk_stats.AccumulateForGmmPreselect(gmm, gselect[
i],
119 spk_stats.Update(fmllr_opts, &transform, &impr, &spk_tot_t);
120 transform_writer.Write(spk, transform);
122 KALDI_LOG <<
"For speaker " << spk <<
", auxf-impr from fMLLR is " 123 << (impr/spk_tot_t) <<
", over " << spk_tot_t <<
" frames.";
129 for (; !feature_reader.Done(); feature_reader.Next()) {
130 string utt = feature_reader.Key();
137 if (gselect_rspecifier ==
"") {
141 if (!gselect_reader.HasKey(utt) ||
142 gselect_reader.Value(utt).size() != feats.
NumRows()) {
143 KALDI_LOG <<
"No gselect information for utterance " << utt
144 <<
" (or wrong size)";
148 const std::vector<std::vector<int32> > &gselect =
149 gselect_reader.Value(utt);
151 spk_stats.AccumulateForGmmPreselect(gmm, gselect[
i],
158 spk_stats.Update(fmllr_opts, &transform, &impr, &utt_tot_t);
159 transform_writer.Write(utt, transform);
161 KALDI_LOG <<
"For utterance " << utt <<
", auxf-impr from fMLLR is " 162 << (impr/utt_tot_t) <<
", over " << utt_tot_t <<
" frames.";
167 KALDI_LOG <<
"Done " << num_done <<
" files, " 168 << num_err <<
" with errors.";
169 KALDI_LOG <<
"Overall fMLLR auxf impr per frame is " 170 << (tot_impr / tot_t) <<
" over " << tot_t <<
" frames.";
171 return (num_done != 0 ? 0 : 1);
172 }
catch(
const std::exception &e) {
173 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.
This does not work with multiple feature transforms.
A templated class for writing objects to an archive or script file; see The Table concept...
void SetUnit()
Sets to zero, except ones along diagonal [for non-square matrices too].
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...
void Register(OptionsItf *opts)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition for Gaussian Mixture Model with diagonal covariances.
BaseFloat AccumulateForGmm(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat weight)
Accumulate stats for a single GMM in the model; returns log likelihood.