38 for (
size_t t = 0; t < post.size(); t++) {
39 for (
size_t i = 0;
i < pdf_post[t].size();
i++) {
40 int32 pdf = pdf_post[t][
i].first;
43 feats.
Row(t), weight);
51 int main(
int argc,
char *argv[]) {
54 using namespace kaldi;
56 "Estimate fMLLR transforms in the space before splicing and linear transforms\n" 57 "such as LDA+MLLT, but using models in the space transformed by these transforms\n" 58 "Requires the original spliced features, and the full LDA+MLLT (or similar) matrix\n" 59 "including the 'rejected' rows (see the program get-full-lda-mat)\n" 60 "Usage: gmm-est-fmllr-raw [options] <model-in> <full-lda-mat-in> " 61 "<feature-rspecifier> <post-rspecifier> <transform-wspecifier>\n";
64 int32 raw_feat_dim = 13;
67 std::string spk2utt_rspecifier;
68 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 69 "utterance-list map");
70 po.
Register(
"raw-feat-dim", &raw_feat_dim,
"Dimension of raw features " 81 std::string model_rxfilename = po.
GetArg(1),
82 full_lda_mat_rxfilename = po.
GetArg(2),
83 feature_rspecifier = po.
GetArg(3),
84 post_rspecifier = po.
GetArg(4),
85 transform_wspecifier = po.
GetArg(5);
91 Input ki(model_rxfilename, &binary);
102 double tot_auxf_impr = 0.0, tot_count = 0.0;
104 int32 num_done = 0, num_err = 0;
105 if (!spk2utt_rspecifier.empty()) {
109 for (; !spk2utt_reader.
Done(); spk2utt_reader.
Next()) {
111 std::string spk = spk2utt_reader.
Key();
112 const std::vector<std::string> &uttlist = spk2utt_reader.
Value();
113 for (
size_t i = 0;
i < uttlist.size();
i++) {
114 std::string utt = uttlist[
i];
115 if (!feature_reader.
HasKey(utt)) {
116 KALDI_WARN <<
"Features not found for utterance " << utt;
120 if (!post_reader.
HasKey(utt)) {
121 KALDI_WARN <<
"Posteriors not found for utterance " << utt;
127 if (static_cast<int32>(post.size()) != feats.
NumRows()) {
128 KALDI_WARN <<
"Size mismatch between posteriors " << post.size()
129 <<
" and features " << feats.
NumRows();
142 accs.Update(opts, &transform, &auxf_impr, &count);
143 transform_writer.
Write(spk, transform);
145 KALDI_LOG <<
"For speaker " << spk <<
", auxf-impr from raw fMLLR is " 146 << (auxf_impr/
count) <<
" over " << count <<
" frames.";
147 tot_auxf_impr += auxf_impr;
152 for (; !feature_reader.
Done(); feature_reader.
Next()) {
153 std::string utt = feature_reader.
Key();
154 if (!post_reader.
HasKey(utt)) {
155 KALDI_WARN <<
"Posteriors not found for utterance " << utt;
162 if (static_cast<int32>(post.size()) != feats.
NumRows()) {
163 KALDI_WARN <<
"Size mismatch between posteriors " << post.size()
164 <<
" and features " << feats.
NumRows();
177 accs.Update(opts, &transform, &auxf_impr, &count);
178 transform_writer.
Write(utt, transform);
180 KALDI_LOG <<
"For utterance " << utt <<
", auxf-impr from raw fMLLR is " 181 << (auxf_impr/
count) <<
" over " << count <<
" frames.";
182 tot_auxf_impr += auxf_impr;
188 KALDI_LOG <<
"Processed " << num_done <<
" utterances, " 189 << num_err <<
" had errors.";
190 KALDI_LOG <<
"Overall raw-fMLLR auxf impr per frame is " 191 << (tot_auxf_impr / tot_count) <<
" over " << tot_count
193 return (num_done != 0 ? 0 : 1);
194 }
catch(
const std::exception &e) {
195 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
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 Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
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...
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...
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const].
const T & Value(const std::string &key)
void Read(std::istream &is, bool binary)
int main(int argc, char *argv[])
void Register(OptionsItf *opts)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
int Read(int argc, const char *const *argv)
Parses the command line options and fills the ParseOptions-registered variables.
std::string GetArg(int param) const
Returns one of the positional parameters; 1-based indexing for argc/argv compatibility.
bool HasKey(const std::string &key)
int NumArgs() const
Number of positional parameters (c.f. argc-1).
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
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)
BaseFloat AccumulateForGmm(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat weight)
Accumulate stats for a single GMM in the model; returns log likelihood.
void ConvertPosteriorToPdfs(const TransitionModel &tmodel, const Posterior &post_in, Posterior *post_out)
Converts a posterior over transition-ids to be a posterior over pdf-ids.
void Read(std::istream &in_stream, bool binary)