63 using namespace kaldi;
65 typedef kaldi::int64 int64;
68 "Accumulate stats for iVector extractor training\n" 69 "Reads in features and Gaussian-level posteriors (typically from a full GMM)\n" 70 "Supports multiple threads, but won't be able to make use of too many at a time\n" 71 "(e.g. more than about 4)\n" 72 "Usage: ivector-extractor-acc-stats [options] <model-in> <feature-rspecifier>" 73 "<posteriors-rspecifier> <stats-out>\n" 75 " fgmm-global-gselect-to-post 1.fgmm '$feats' 'ark:gunzip -c gselect.1.gz|' ark:- | \\\n" 76 " ivector-extractor-acc-stats 2.ie '$feats' ark,s,cs:- 2.1.acc\n";
82 po.
Register(
"binary", &binary,
"Write output in binary mode");
88 if (po.NumArgs() != 4) {
93 std::string ivector_extractor_rxfilename = po.GetArg(1),
94 feature_rspecifier = po.GetArg(2),
95 posteriors_rspecifier = po.GetArg(3),
96 accs_wxfilename = po.GetArg(4);
119 int32 num_done = 0, num_err = 0;
124 for (; !feature_reader.Done(); feature_reader.Next()) {
125 std::string key = feature_reader.Key();
126 if (!posteriors_reader.HasKey(key)) {
127 KALDI_WARN <<
"No posteriors for utterance " << key;
132 const Posterior &posterior = posteriors_reader.Value(key);
134 if (static_cast<int32>(posterior.size()) != mat.
NumRows()) {
135 KALDI_WARN <<
"Size mismatch between posterior " << (posterior.size())
136 <<
" and features " << (mat.
NumRows()) <<
" for utterance " 142 sequencer.Run(
new IvectorTask(extractor, mat, posterior, &stats));
144 tot_t += posterior.size();
151 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_err
152 <<
" with errors. Total frames " << tot_t;
155 Output ko(accs_wxfilename, binary);
156 stats.Write(ko.Stream(), binary);
159 KALDI_LOG <<
"Wrote stats to " << accs_wxfilename;
161 return (num_done != 0 ? 0 : 1);
162 }
catch(
const std::exception &e) {
163 std::cerr << e.what();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
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...
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 Register(OptionsItf *opts)