211   using namespace kaldi;
   213   typedef kaldi::int64 int64;
   216         "Extract iVectors for utterances, using a trained iVector extractor,\n"   217         "and features and Gaussian-level posteriors\n"   218         "Usage:  ivector-extract [options] <model-in> <feature-rspecifier> "   219         "<posteriors-rspecifier> <ivector-wspecifier>\n"   221         " fgmm-global-gselect-to-post 1.ubm '$feats' 'ark:gunzip -c gselect.1.gz|' ark:- | \\\n"   222         "  ivector-extract final.ie '$feats' ark,s,cs:- ark,t:ivectors.1.ark\n";
   225     bool compute_objf_change = 
true;
   227     std::string spk2utt_rspecifier;
   229     po.
Register(
"compute-objf-change", &compute_objf_change,
   230                 "If true, compute the change in objective function from using "   231                 "nonzero iVector (a potentially useful diagnostic).  Combine "   232                 "with --verbose=2 for per-utterance information");
   233     po.Register(
"spk2utt", &spk2utt_rspecifier, 
"Supply this option if you "   234                 "want iVectors to be output at the per-speaker level, estimated "   235                 "using stats accumulated from multiple utterances.  Note: this "   236                 "is not the normal way iVectors are obtained for speaker-id. "   237                 "This option will cause the program to ignore the --num-threads "   245     if (po.NumArgs() != 4) {
   250     std::string ivector_extractor_rxfilename = po.GetArg(1),
   251         feature_rspecifier = po.GetArg(2),
   252         posterior_rspecifier = po.GetArg(3),
   253         ivectors_wspecifier = po.GetArg(4);
   256     if (spk2utt_rspecifier.empty()) {
   263       double tot_auxf_change = 0.0, tot_t = 0.0;
   264       int32 num_done = 0, num_err = 0;
   272         for (; !feature_reader.Done(); feature_reader.Next()) {
   273           std::string utt = feature_reader.Key();
   274           if (!posterior_reader.HasKey(utt)) {
   275             KALDI_WARN << 
"No posteriors for utterance " << utt;
   280           Posterior posterior = posterior_reader.Value(utt);
   282           if (static_cast<int32>(posterior.size()) != mat.
NumRows()) {
   283             KALDI_WARN << 
"Size mismatch between posterior " << posterior.size()
   284                        << 
" and features " << mat.
NumRows() << 
" for utterance "   290           double *auxf_ptr = (compute_objf_change ? &tot_auxf_change : NULL );
   293               max_count_scale = 1.0;
   295             max_count_scale = opts.
max_count / this_t;
   296             KALDI_LOG << 
"Scaling stats for utterance " << utt << 
" by scale "   297                       << max_count_scale << 
" due to --max-count="   306                                                &ivector_writer, auxf_ptr));
   314       KALDI_LOG << 
"Done " << num_done << 
" files, " << num_err
   315                 << 
" with errors.  Total (weighted) frames " << tot_t;
   316       if (compute_objf_change)
   317         KALDI_LOG << 
"Overall average objective-function change from estimating "   318                   << 
"ivector was " << (tot_auxf_change / tot_t) << 
" per frame "   319                   << 
" over " << tot_t << 
" (weighted) frames.";
   321       return (num_done != 0 ? 0 : 1);
   324                    "--spk2utt option is incompatible with --num-threads option");
   330                            posterior_rspecifier,
   331                            ivectors_wspecifier);
   333   } 
catch(
const std::exception &e) {
   334     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
void Register(OptionsItf *opts)
 
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)
 
BaseFloat TotalPosterior(const Posterior &post)
Returns the total of all the weights in "post". 
 
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...
 
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
 
void ScalePosterior(BaseFloat scale, Posterior *post)
Scales the BaseFloat (weight) element in the posterior entries. 
 
#define KALDI_ASSERT(cond)
 
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix). 
 
int32 RunPerSpeaker(const std::string &ivector_extractor_rxfilename, const IvectorEstimationOptions &opts, bool compute_objf_change, const std::string &spk2utt_rspecifier, const std::string &feature_rspecifier, const std::string &posterior_rspecifier, const std::string &ivector_wspecifier)
 
void Register(OptionsItf *opts)