52 using namespace kaldi;
54 "Estimate fMLLR transforms in the space before splicing and linear transforms\n" 55 "such as LDA+MLLT, but using models in the space transformed by these transforms\n" 56 "Requires the original spliced features, and the full LDA+MLLT (or similar) matrix\n" 57 "including the 'rejected' rows (see the program get-full-lda-mat). Reads in\n" 58 "Gaussian-level posteriors.\n" 59 "Usage: gmm-est-fmllr-raw-gpost [options] <model-in> <full-lda-mat-in> " 60 "<feature-rspecifier> <gpost-rspecifier> <transform-wspecifier>\n";
63 int32 raw_feat_dim = 13;
66 std::string spk2utt_rspecifier;
67 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 68 "utterance-list map");
69 po.Register(
"raw-feat-dim", &raw_feat_dim,
"Dimension of raw features " 75 if (po.NumArgs() != 5) {
80 std::string model_rxfilename = po.GetArg(1),
81 full_lda_mat_rxfilename = po.GetArg(2),
82 feature_rspecifier = po.GetArg(3),
83 gpost_rspecifier = po.GetArg(4),
84 transform_wspecifier = po.GetArg(5);
90 Input ki(model_rxfilename, &binary);
91 trans_model.
Read(ki.Stream(), binary);
92 am_gmm.
Read(ki.Stream(), binary);
101 double tot_auxf_impr = 0.0, tot_count = 0.0;
103 int32 num_done = 0, num_err = 0;
104 if (!spk2utt_rspecifier.empty()) {
108 for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
110 std::string spk = spk2utt_reader.Key();
111 const std::vector<std::string> &uttlist = spk2utt_reader.Value();
112 for (
size_t i = 0;
i < uttlist.size();
i++) {
113 std::string utt = uttlist[
i];
114 if (!feature_reader.HasKey(utt)) {
115 KALDI_WARN <<
"Features not found for utterance " << utt;
119 if (!gpost_reader.HasKey(utt)) {
120 KALDI_WARN <<
"Gaussian-level posteriors not found for utterance " << utt;
125 const GaussPost &gpost = gpost_reader.Value(utt);
126 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
127 KALDI_WARN <<
"Size mismatch between gposteriors " << gpost.size()
128 <<
" and features " << feats.
NumRows();
141 accs.Update(opts, &transform, &auxf_impr, &count);
142 transform_writer.Write(spk, transform);
144 KALDI_LOG <<
"For speaker " << spk <<
", auxf-impr from raw fMLLR is " 145 << (auxf_impr/
count) <<
" over " << count <<
" frames.";
146 tot_auxf_impr += auxf_impr;
151 for (; !feature_reader.Done(); feature_reader.Next()) {
152 std::string utt = feature_reader.Key();
153 if (!gpost_reader.HasKey(utt)) {
154 KALDI_WARN <<
"Gaussian-level posteriors not found for utterance " << utt;
159 const GaussPost &gpost = gpost_reader.Value(utt);
161 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
162 KALDI_WARN <<
"Size mismatch between posteriors " << gpost.size()
163 <<
" and features " << feats.
NumRows();
176 accs.Update(opts, &transform, &auxf_impr, &count);
177 transform_writer.Write(utt, transform);
179 KALDI_LOG <<
"For utterance " << utt <<
", auxf-impr from raw fMLLR is " 180 << (auxf_impr/
count) <<
" over " << count <<
" frames.";
181 tot_auxf_impr += auxf_impr;
187 KALDI_LOG <<
"Processed " << num_done <<
" utterances, " 188 << num_err <<
" had errors.";
189 KALDI_LOG <<
"Overall raw-fMLLR auxf impr per frame is " 190 << (tot_auxf_impr / tot_count) <<
" over " << tot_count
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...
A templated class for writing objects to an archive or script file; see The Table concept...
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...
void Read(std::istream &is, bool binary)
void Register(OptionsItf *opts)
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).
void AccStatsForUtterance(const TransitionModel &trans_model, const AmDiagGmm &am_gmm, const GaussPost &gpost, const Matrix< BaseFloat > &feats, FmllrRawAccs *accs)
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)