29 using namespace kaldi;
33 "Precompute Gaussian indices and convert immediately to top-n\n" 34 "posteriors (useful in iVector extraction with diagonal UBMs)\n" 35 "See also: gmm-gselect, fgmm-gselect, fgmm-global-gselect-to-post\n" 36 " (e.g. in training UBMs, SGMMs, tied-mixture systems)\n" 37 " For each frame, gives a list of the n best Gaussian indices,\n" 38 " sorted from best to worst.\n" 39 "Usage: gmm-global-get-post [options] <model-in> <feature-rspecifier> <post-wspecifier>\n" 40 "e.g.: gmm-global-get-post --n=20 1.gmm \"ark:feature-command |\" \"ark,t:|gzip -c >post.1.gz\"\n";
45 po.Register(
"n", &num_post,
"Number of Gaussians to keep per frame\n");
46 po.Register(
"min-post", &min_post,
"Minimum posterior we will output " 47 "before pruning and renormalizing (e.g. 0.01)");
50 if (po.NumArgs() != 3) {
55 std::string model_filename = po.GetArg(1),
56 feature_rspecifier = po.GetArg(2),
57 post_wspecifier = po.GetArg(3);
64 if (num_post > num_gauss) {
65 KALDI_WARN <<
"You asked for " << num_post <<
" Gaussians but GMM " 66 <<
"only has " << num_gauss <<
", returning this many. ";
70 double tot_like = 0.0;
71 kaldi::int64 tot_t = 0;
76 int32 num_done = 0, num_err = 0;
77 for (; !feature_reader.Done(); feature_reader.Next()) {
78 std::string utt = feature_reader.Key();
82 KALDI_WARN <<
"Empty features for utterance " << utt;
87 KALDI_WARN <<
"Dimension mismatch for utterance " << utt
88 <<
": got " << feats.
NumCols() <<
", expected " << gmm.
Dim();
92 vector<vector<int32> > gselect(T);
100 double log_like_this_file = 0.0;
101 for (int32 t = 0; t < T; t++) {
102 log_like_this_file +=
104 min_post, &(post[t]));
106 KALDI_VLOG(1) <<
"Processed utterance " << utt <<
", average likelihood " 107 << (log_like_this_file / T) <<
" over " << T <<
" frames";
108 tot_like += log_like_this_file;
111 post_writer.Write(utt, post);
115 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_err
116 <<
" with errors, average UBM log-likelihood is " 117 << (tot_like/tot_t) <<
" over " << tot_t <<
" frames.";
119 if (num_done != 0)
return 0;
121 }
catch(
const std::exception &e) {
122 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 Dim() const
Returns the dimensionality of the Gaussian mean vectors.
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
BaseFloat VectorToPosteriorEntry(const VectorBase< BaseFloat > &log_likes, int32 num_gselect, BaseFloat min_post, std::vector< std::pair< int32, BaseFloat > > *post_entry)
Given a vector of log-likelihoods (typically of Gaussians in a GMM but could be of pdf-ids)...
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)
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].
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
int32 NumGauss() const
Returns the number of mixture components in the GMM.
void LogLikelihoods(const VectorBase< BaseFloat > &data, Vector< BaseFloat > *loglikes) const
Outputs the per-component log-likelihoods.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition for Gaussian Mixture Model with diagonal covariances.