29 using namespace kaldi;
31 "Apply online cepstral mean (and possibly variance) computation online,\n" 32 "using the same code as used for online decoding in the 'new' setup in\n" 33 "online2/ and online2bin/. If the --spk2utt option is used, it uses\n" 34 "prior utterances from the same speaker to back off to at the utterance\n" 35 "beginning. See also apply-cmvn-sliding.\n" 37 "Usage: apply-cmvn-online [options] <global-cmvn-stats> <feature-rspecifier> " 38 "<feature-wspecifier>\n" 39 "e.g. apply-cmvn-online 'matrix-sum scp:data/train/cmvn.scp -|' data/train/split8/1/feats.scp ark:-\n" 40 "or: apply-cmvn-online --spk2utt=ark:data/train/split8/1/spk2utt 'matrix-sum scp:data/train/cmvn.scp -|' " 41 " data/train/split8/1/feats.scp ark:-\n";
47 std::string spk2utt_rspecifier;
48 po.
Register(
"spk2utt", &spk2utt_rspecifier,
"rspecifier for speaker to " 49 "utterance-list map");
54 if (po.NumArgs() != 3) {
59 std::string global_stats_rxfilename = po.GetArg(1),
60 feature_rspecifier = po.GetArg(2),
61 feature_wspecifier = po.GetArg(3);
71 int32 num_done = 0, num_err = 0;
74 if (spk2utt_rspecifier !=
"") {
78 for (; !spk2utt_reader.Done(); spk2utt_reader.Next()) {
80 const std::vector<std::string> &uttlist = spk2utt_reader.Value();
81 for (
size_t i = 0;
i < uttlist.size();
i++) {
82 std::string utt = uttlist[
i];
83 if (!feature_reader.HasKey(utt)) {
84 KALDI_WARN <<
"No features for utterance " << utt;
98 for (int32 t = 0; t < feats.
NumRows(); t++) {
100 online_cmvn.GetFrame(t, &row);
102 online_cmvn.GetState(feats.
NumRows() - 1, &cmvn_state);
106 feature_writer.Write(utt, normalized_feats);
111 for (; !feature_reader.Done(); feature_reader.Next()) {
112 std::string utt = feature_reader.Key();
123 for (int32 t = 0; t < feats.
NumRows(); t++) {
125 online_cmvn.GetFrame(t, &row);
129 feature_writer.Write(utt, normalized_feats);
133 KALDI_LOG <<
"Applied online CMVN to " << num_done <<
" files, or " 134 << tot_t <<
" frames.";
135 return (num_done != 0 ? 0 : 1);
136 }
catch(
const std::exception &e) {
137 std::cerr << e.what();
This class takes a Matrix<BaseFloat> and wraps it as an OnlineFeatureInterface: this can be useful wh...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
This class does an online version of the cepstral mean and [optionally] variance, but note that this ...
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)
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...
Struct OnlineCmvnState stores the state of CMVN adaptation between utterances (but not the state of t...
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
void Register(ParseOptions *po)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...