26 int main(
int argc,
char *argv[]) {
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");
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++) {
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++) {
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).
void PrintUsage(bool print_command_line=false)
Prints the usage documentation [provided in the constructor].
This class does an online version of the cepstral mean and [optionally] variance, but note that this ...
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)
Gets the feature vector for this frame.
A templated class for writing objects to an archive or script file; see The Table concept...
void Write(const std::string &key, const T &value) const
void Register(const std::string &name, bool *ptr, const std::string &doc)
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
void GetState(int32 cur_frame, OnlineCmvnState *cmvn_state)
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...
const T & Value(const std::string &key)
int main(int argc, char *argv[])
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...
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).
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...