150 using namespace kaldi;
153 typedef kaldi::int64 int64;
156 "Get frame-by-frame examples of data for nnet3 neural network training.\n" 157 "This program is similar to nnet3-get-egs, but the targets here are " 158 "dense matrices instead of posteriors (sparse matrices).\n" 159 "This is useful when you want the targets to be continuous real-valued " 160 "with the neural network possibly trained with a quadratic objective\n" 162 "Usage: nnet3-get-egs-dense-targets --num-targets=<n> [options] " 163 "<features-rspecifier> <targets-rspecifier> <egs-out>\n" 165 "An example [where $feats expands to the actual features]:\n" 166 "nnet-get-egs-dense-targets --num-targets=26 --left-context=12 \\\n" 167 "--right-context=9 --num-frames=8 \"$feats\" \\\n" 168 "\"ark:copy-matrix ark:exp/snrs/snr.1.ark ark:- |\"\n" 172 bool compress =
true;
173 int32 num_targets = -1, length_tolerance = 100,
174 targets_length_tolerance = 2,
175 online_ivector_period = 1;
180 std::string online_ivector_rspecifier;
184 po.Register(
"compress", &compress,
"If true, write egs with input features " 185 "in compressed format (recommended). This is " 186 "only relevant if the features being read are un-compressed; " 187 "if already compressed, we keep we same compressed format when " 189 po.Register(
"num-targets", &num_targets,
"Output dimension in egs, " 190 "only used to check targets have correct dim if supplied.");
191 po.Register(
"ivectors", &online_ivector_rspecifier,
"Alias for " 192 "--online-ivectors option, for back compatibility");
193 po.Register(
"online-ivectors", &online_ivector_rspecifier,
"Rspecifier of " 194 "ivector features, as a matrix.");
195 po.Register(
"online-ivector-period", &online_ivector_period,
"Number of " 196 "frames between iVectors in matrices supplied to the " 197 "--online-ivectors option");
198 po.Register(
"length-tolerance", &length_tolerance,
"Tolerance for " 199 "difference in num-frames between feat and ivector matrices");
200 po.Register(
"targets-length-tolerance", &targets_length_tolerance,
202 "difference in num-frames (after subsampling) between " 203 "feature and target matrices");
208 if (po.NumArgs() != 3) {
216 std::string feature_rspecifier = po.GetArg(1),
217 matrix_rspecifier = po.GetArg(2),
218 examples_wspecifier = po.GetArg(3);
228 online_ivector_rspecifier);
232 for (; !feat_reader.Done(); feat_reader.Next()) {
233 std::string key = feat_reader.Key();
235 if (!matrix_reader.HasKey(key)) {
236 KALDI_WARN <<
"No target matrix for key " << key;
241 if (!online_ivector_rspecifier.empty()) {
242 if (!online_ivector_reader.HasKey(key)) {
243 KALDI_WARN <<
"No iVectors for utterance " << key;
249 online_ivector_feats = &(online_ivector_reader.Value(key));
253 if (online_ivector_feats != NULL &&
255 online_ivector_period)) > length_tolerance
256 || online_ivector_feats->
NumRows() == 0)) {
258 <<
" and iVectors " << online_ivector_feats->
NumRows()
259 <<
"exceeds tolerance " << length_tolerance;
264 if (!
ProcessFile(feats, online_ivector_feats, online_ivector_period,
265 target_matrix, key, compress, num_targets,
266 targets_length_tolerance,
267 &utt_splitter, &example_writer))
272 KALDI_WARN << num_err <<
" utterances had errors and could " 275 return utt_splitter.ExitStatus();
276 }
catch(
const std::exception &e) {
277 std::cerr << e.what() <<
'\n';
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
This class is a wrapper that enables you to store a matrix in one of three forms: either as a Matrix<...
A templated class for writing objects to an archive or script file; see The Table concept...
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...
static bool ProcessFile(const discriminative::SplitDiscriminativeSupervisionOptions &config, const TransitionModel &tmodel, const MatrixBase< BaseFloat > &feats, const MatrixBase< BaseFloat > *ivector_feats, int32 ivector_period, const discriminative::DiscriminativeSupervision &supervision, const std::string &utt_id, bool compress, UtteranceSplitter *utt_splitter, NnetDiscriminativeExampleWriter *example_writer)
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
void Register(OptionsItf *po)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
MatrixIndexT NumRows() const
void ComputeDerived()
This function decodes 'num_frames_str' into 'num_frames', and ensures that the members of 'num_frames...