31 using namespace kaldi;
34 "Accumulate MLLT (global STC) statistics\n" 35 "Usage: gmm-acc-mllt [options] <model-in> <feature-rspecifier> <posteriors-rspecifier> <stats-out>\n" 37 " gmm-acc-mllt 1.mdl scp:train.scp ark:1.post 1.macc\n";
42 po.Register(
"binary", &binary,
"Write output in binary mode");
43 po.Register(
"rand-prune", &rand_prune,
"Randomized pruning parameter to speed up " 44 "accumulation (larger -> more pruning. May exceed one).");
47 if (po.NumArgs() != 4) {
52 std::string model_filename = po.GetArg(1),
53 feature_rspecifier = po.GetArg(2),
54 posteriors_rspecifier = po.GetArg(3),
55 accs_wxfilename = po.GetArg(4);
57 using namespace kaldi;
64 Input ki(model_filename, &binary);
65 trans_model.
Read(ki.Stream(), binary);
66 am_gmm.
Read(ki.Stream(), binary);
71 double tot_like = 0.0;
77 int32 num_done = 0, num_no_posterior = 0, num_other_error = 0;
78 for (; !feature_reader.Done(); feature_reader.Next()) {
79 std::string key = feature_reader.Key();
80 if (!posteriors_reader.HasKey(key)) {
84 const Posterior &posterior = posteriors_reader.Value(key);
86 if (static_cast<int32>(posterior.size()) != mat.
NumRows()) {
87 KALDI_WARN <<
"Posterior vector has wrong size "<< (posterior.size()) <<
" vs. "<< (mat.
NumRows());
93 BaseFloat tot_like_this_file = 0.0, tot_weight = 0.0;
97 for (
size_t i = 0;
i < posterior.size();
i++) {
98 for (
size_t j = 0;
j < pdf_posterior[
i].size();
j++) {
99 int32 pdf_id = pdf_posterior[
i][
j].first;
102 tot_like_this_file += mllt_accs.AccumulateFromGmm(am_gmm.
GetPdf(pdf_id),
105 tot_weight += weight;
108 KALDI_LOG <<
"Average like for this file is " 109 << (tot_like_this_file/tot_weight) <<
" over " 110 << tot_weight <<
" frames.";
111 tot_like += tot_like_this_file;
113 if (num_done % 10 == 0)
114 KALDI_LOG <<
"Avg like per frame so far is " 119 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_no_posterior
120 <<
" with no posteriors, " << num_other_error
121 <<
" with other errors.";
123 KALDI_LOG <<
"Overall avg like per frame (Gaussian only) = " 124 << (tot_like/tot_t) <<
" over " << tot_t <<
" frames.";
128 return (num_done != 0 ? 0 : 1);
129 }
catch(
const std::exception &e) {
130 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
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].
void Read(std::istream &is, bool binary)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
DiagGmm & GetPdf(int32 pdf_index)
Accessors.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
void WriteKaldiObject(const C &c, const std::string &filename, bool binary)
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)
A class for estimating Maximum Likelihood Linear Transform, also known as global Semi-tied Covariance...