58 using namespace kaldi;
60 "Estimate global fMLLR transforms, either per utterance or for the supplied\n" 61 "set of speakers (spk2utt option). Reads posteriors (on transition-ids). Writes\n" 62 "to a table of matrices.\n" 63 "Usage: gmm-est-fmllr [options] <model-in> " 64 "<feature-rspecifier> <post-rspecifier> <transform-wspecifier>\n";
68 string spk2utt_rspecifier;
69 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 70 "utterance-list map");
75 if (po.NumArgs() != 4) {
81 model_rxfilename = po.GetArg(1),
82 feature_rspecifier = po.GetArg(2),
83 post_rspecifier = po.GetArg(3),
84 trans_wspecifier = po.GetArg(4);
90 Input ki(model_rxfilename, &binary);
91 trans_model.
Read(ki.Stream(), binary);
92 am_gmm.
Read(ki.Stream(), binary);
97 double tot_impr = 0.0, tot_t = 0.0;
101 int32 num_done = 0, num_no_post = 0, num_other_error = 0;
102 if (spk2utt_rspecifier !=
"") {
106 for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
108 string spk = spk2utt_reader.Key();
109 const vector<string> &uttlist = spk2utt_reader.Value();
110 for (
size_t i = 0;
i < uttlist.size();
i++) {
111 std::string utt = uttlist[
i];
112 if (!feature_reader.HasKey(utt)) {
113 KALDI_WARN <<
"Did not find features for utterance " << utt;
117 if (!post_reader.HasKey(utt)) {
118 KALDI_WARN <<
"Did not find posteriors for utterance " << utt;
123 const Posterior &post = post_reader.Value(utt);
124 if (static_cast<int32>(post.size()) != feats.
NumRows()) {
125 KALDI_WARN <<
"Posterior vector has wrong size " << (post.size())
126 <<
" vs. " << (feats.
NumRows());
140 spk_stats.Update(fmllr_opts, &transform, &impr, &spk_tot_t);
141 transform_writer.Write(spk, transform);
143 KALDI_LOG <<
"For speaker " << spk <<
", auxf-impr from fMLLR is " 144 << (impr/spk_tot_t) <<
", over " << spk_tot_t <<
" frames.";
150 for (; !feature_reader.Done(); feature_reader.Next()) {
151 string utt = feature_reader.Key();
152 if (!post_reader.HasKey(utt)) {
153 KALDI_WARN <<
"Did not find posts for utterance " 159 const Posterior &post = post_reader.Value(utt);
161 if (static_cast<int32>(post.size()) != feats.
NumRows()) {
162 KALDI_WARN <<
"Posterior has wrong size " << (post.size())
163 <<
" vs. " << (feats.
NumRows());
178 spk_stats.Update(fmllr_opts, &transform, &impr, &utt_tot_t);
179 transform_writer.Write(utt, transform);
181 KALDI_LOG <<
"For utterance " << utt <<
", auxf-impr from fMLLR is " 182 << (impr/utt_tot_t) <<
", over " << utt_tot_t <<
" frames.";
188 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_no_post
189 <<
" with no posts, " << num_other_error <<
" with other errors.";
190 KALDI_LOG <<
"Overall fMLLR auxf impr per frame is " 191 << (tot_impr / tot_t) <<
" over " << tot_t <<
" frames.";
192 return (num_done != 0 ? 0 : 1);
193 }
catch(
const std::exception &e) {
194 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...
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
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).
void Read(std::istream &in_stream, bool binary)