56 using namespace kaldi;
58 "Estimate global fMLLR transforms, either per utterance or for the supplied\n" 59 "set of speakers (spk2utt option). Reads Gaussian-level posteriors. Writes\n" 60 "to a table of matrices.\n" 61 "Usage: gmm-est-fmllr-gpost [options] <model-in> " 62 "<feature-rspecifier> <gpost-rspecifier> <transform-wspecifier>\n";
66 string spk2utt_rspecifier;
67 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 68 "utterance-list map");
73 if (po.NumArgs() != 4) {
79 model_rxfilename = po.GetArg(1),
80 feature_rspecifier = po.GetArg(2),
81 gpost_rspecifier = po.GetArg(3),
82 trans_wspecifier = po.GetArg(4);
88 Input ki(model_rxfilename, &binary);
89 trans_model.
Read(ki.Stream(), binary);
90 am_gmm.
Read(ki.Stream(), binary);
95 double tot_impr = 0.0, tot_t = 0.0;
99 int32 num_done = 0, num_no_gpost = 0, num_other_error = 0;
100 if (spk2utt_rspecifier !=
"") {
104 for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
106 string spk = spk2utt_reader.Key();
107 const vector<string> &uttlist = spk2utt_reader.Value();
108 for (
size_t i = 0;
i < uttlist.size();
i++) {
109 std::string utt = uttlist[
i];
110 if (!feature_reader.HasKey(utt)) {
111 KALDI_WARN <<
"Did not find features for utterance " << utt;
115 if (!gpost_reader.HasKey(utt)) {
116 KALDI_WARN <<
"Did not find posteriors for utterance " << utt;
121 const GaussPost &gpost = gpost_reader.Value(utt);
122 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
123 KALDI_WARN <<
"GaussPost vector has wrong size " << (gpost.size())
124 <<
" vs. " << (feats.
NumRows());
138 spk_stats.Update(fmllr_opts, &transform, &impr, &spk_tot_t);
139 transform_writer.Write(spk, transform);
141 KALDI_LOG <<
"For speaker " << spk <<
", auxf-impr from fMLLR is " 142 << (impr/spk_tot_t) <<
", over " << spk_tot_t <<
" frames.\n";
148 for (; !feature_reader.Done(); feature_reader.Next()) {
149 string utt = feature_reader.Key();
150 if (!gpost_reader.HasKey(utt)) {
151 KALDI_WARN <<
"Did not find gposts for utterance " 157 const GaussPost &gpost = gpost_reader.Value(utt);
159 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
160 KALDI_WARN <<
"GaussPost has wrong size " << (gpost.size())
161 <<
" vs. " << (feats.
NumRows());
176 spk_stats.Update(fmllr_opts, &transform, &impr, &utt_tot_t);
177 transform_writer.Write(utt, transform);
179 KALDI_LOG <<
"For utterancer " << utt <<
", auxf-impr from fMLLR is " 180 << (impr/utt_tot_t) <<
", over " << utt_tot_t <<
" frames.";
186 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_no_gpost
187 <<
" with no gposts, " << num_other_error <<
" with other errors.";
188 KALDI_LOG <<
"Overall fMLLR auxf impr per frame is " 189 << (tot_impr / tot_t) <<
" over " << tot_t <<
" frames.";
190 return (num_done != 0 ? 0 : 1);
191 }
catch(
const std::exception &e) {
192 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
This does not work with multiple feature transforms.
void AccumulateForUtterance(const Matrix< BaseFloat > &feats, const GaussPost &gpost, const TransitionModel &trans_model, const AmDiagGmm &am_gmm, FmllrDiagGmmAccs *spk_stats)
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].
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...
void Read(std::istream &is, bool binary)
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).
std::vector< std::vector< std::pair< int32, Vector< BaseFloat > > > > GaussPost
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance.
void Read(std::istream &in_stream, bool binary)