28     using namespace kaldi;
    31         "Copy cepstral mean/variance stats so that some dimensions have 'fake' stats\n"    32         "that will skip normalization\n"    33         "Usage: modify-cmvn-stats [options] [<fake-dims>] <in-rspecifier> <out-wspecifier>\n"    34         "e.g.: modify-cmvn-stats 13:14:15 ark:- ark:-\n"    35         "or: modify-cmvn-stats --convert-to-mean-and-var=true ark:- ark:-\n"    36         "See also: compute-cmvn-stats\n";
    38     bool convert_to_mean_and_var = 
false;
    42     po.Register(
"convert-to-mean-and-var", &convert_to_mean_and_var,
    43                 "If true, convert the stats to a matrix containing the mean "    44                 "and the centered variance in each dimension");
    48     if (po.NumArgs() != 2 && po.NumArgs() != 3) {
    56     std::string skip_dims_str, rspecifier, wspecifier;
    57     if (po.NumArgs() == 3) {
    58       skip_dims_str = po.GetArg(1);
    59       rspecifier = po.GetArg(2);
    60       wspecifier = po.GetArg(3);
    62       rspecifier = po.GetArg(1);
    63       wspecifier = po.GetArg(2);
    66     std::vector<int32> skip_dims;
    68       KALDI_ERR << 
"Bad first argument (should be colon-separated list of "    75     for (; !reader.Done(); reader.Next()) {
    78       if (mat.NumRows() != 2)
    79         KALDI_ERR << 
"Expected input to be CMVN stats (should have two rows)";
    82       if (!convert_to_mean_and_var) {
    83         writer.Write(reader.Key(), mat);
    86         int32 dim = mat.NumCols() - 1;
    87         double count = mat(0, dim);
    90           KALDI_WARN << 
"Zero or negative count for speaker " << reader.Key()
    91                      << 
", not outputting mean and variance stats.";
    95           double mean = mat(0, 
i) / 
count,
    96               variance = mat(1, 
i) / count - mean * mean;
    97           modified_mat(0, 
i) = mean;
    98           modified_mat(1, 
i) = variance;
   100         writer.Write(reader.Key(), modified_mat);
   104     KALDI_LOG << 
"Modified " << num_done << 
" sets of stats.";
   105     return (num_done != 0 ? 0 : 1);
   106   } 
catch(
const std::exception &e) {
   107     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
bool SplitStringToIntegers(const std::string &full, const char *delim, bool omit_empty_strings, std::vector< I > *out)
Split a string (e.g. 
 
A templated class for writing objects to 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...
 
A templated class for reading objects sequentially from an archive or script file; see The Table conc...
 
void FakeStatsForSomeDims(const std::vector< int32 > &dims, MatrixBase< double > *stats)
Modify the stats so that for some dimensions (specified in "dims"), we replace them with "fake" stats...