40 for (
size_t i = 0;
i < gpost.size();
i++) {
41 for (
size_t j = 0;
j < gpost[
i].size();
j++) {
42 int32 pdf_id = gpost[
i][
j].first;
45 feats.
Row(
i), posterior);
53 int main(
int argc,
char *argv[]) {
56 using namespace kaldi;
58 "Accumulate gradient scatter from training set, either per utterance or \n" 59 "for the supplied set of speakers (spk2utt option). Reads Gaussian-level \n" 60 "posterior to accumulate fMLLR stats for each speaker/utterance. Writes \n" 61 "gradient scatter matrix.\n" 62 "Usage: gmm-basis-fmllr-accs-gpost [options] <model-in> <feature-rspecifier>" 63 "<post-rspecifier> <accs-wspecifier>\n";
65 bool binary_write =
true;
66 string spk2utt_rspecifier;
68 po.
Register(
"binary", &binary_write,
"Write output in binary mode");
69 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 70 "utterance-list map");
79 model_rxfilename = po.
GetArg(1),
80 feature_rspecifier = po.
GetArg(2),
81 gpost_rspecifier = po.
GetArg(3),
82 accs_wspecifier = po.
GetArg(4);
88 Input ki(model_rxfilename, &binary);
96 int32 num_done = 0, num_no_post = 0, num_other_error = 0;
97 if (spk2utt_rspecifier !=
"") {
102 for (; !spk2utt_reader.
Done(); spk2utt_reader.
Next()) {
104 string spk = spk2utt_reader.
Key();
105 const vector<string> &uttlist = spk2utt_reader.
Value();
106 for (
size_t i = 0;
i < uttlist.size();
i++) {
107 std::string utt = uttlist[
i];
108 if (!feature_reader.
HasKey(utt)) {
109 KALDI_WARN <<
"Did not find features for utterance " << utt;
113 if (!gpost_reader.
HasKey(utt)) {
114 KALDI_WARN <<
"Did not find posteriors for utterance " << utt;
120 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
121 KALDI_WARN <<
"GaussPost has wrong size " << (gpost.size())
122 <<
" vs. " << (feats.
NumRows());
131 basis_accs.AccuGradientScatter(spk_stats);
134 KALDI_LOG <<
"Accumulate statistics from " << num_spk <<
" speakers";
138 for (; !feature_reader.
Done(); feature_reader.
Next()) {
139 string utt = feature_reader.
Key();
140 if (!gpost_reader.
HasKey(utt)) {
141 KALDI_WARN <<
"Did not find posts for utterance " 149 if (static_cast<int32>(gpost.size()) != feats.
NumRows()) {
150 KALDI_WARN <<
"GaussPost has wrong size " << (gpost.size())
151 <<
" vs. " << (feats.
NumRows());
160 basis_accs.AccuGradientScatter(utt_stats);
165 Output ko(accs_wspecifier, binary_write);
166 basis_accs.Write(ko.
Stream(), binary_write);
168 KALDI_LOG <<
"Done " << num_done <<
" files, " << num_no_post
169 <<
" with no posts, " << num_other_error <<
" with other errors.";
170 KALDI_LOG <<
"Written gradient scatter to " << accs_wspecifier;
171 return (num_done != 0 ? 0 : 1);
172 }
catch(
const std::exception& e) {
173 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].
This does not work with multiple feature transforms.
void AccumulateFromPosteriors(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, const VectorBase< BaseFloat > &posteriors)
Accumulate stats for a GMM, given supplied posteriors.
void AccumulateForUtterance(const Matrix< BaseFloat > &feats, const GaussPost &gpost, const TransitionModel &trans_model, const AmDiagGmm &am_gmm, FmllrDiagGmmAccs *spk_stats)
void Register(const std::string &name, bool *ptr, const std::string &doc)
Allows random access to a collection of objects in an archive or script file; see The Table concept...
The class ParseOptions is for parsing command-line options; see Parsing command-line options for more...
Stats for fMLLR subspace estimation.
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)
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.
int main(int argc, char *argv[])
A class representing a vector.
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
std::vector< std::vector< std::pair< int32, Vector< BaseFloat > > > > GaussPost
GaussPost is a typedef for storing Gaussian-level posteriors for an utterance.
void Read(std::istream &in_stream, bool binary)