26   using namespace kaldi;
    30         "Copies a table of iVectors but subtracts the global mean as\n"    31         "it does so.  The mean may be specified as the first argument; if not,\n"    32         "the sum of the input iVectors is used.\n"    34         "Usage: ivector-subtract-global-mean <ivector-rspecifier> <ivector-wspecifier>\n"    35         "or: ivector-subtract-global-mean <mean-rxfliename> <ivector-rspecifier> <ivector-wspecifier>\n"    36         "e.g.: ivector-subtract-global-mean scp:ivectors.scp ark:-\n"    37         "or: ivector-subtract-global-mean mean.vec scp:ivectors.scp ark:-\n"    38         "See also: ivector-mean\n";
    42     bool subtract_mean = 
true;
    43     po.Register(
"subtract-mean", &subtract_mean,
    44                 "If true, subtract mean; if false, just copy the input.");
    48     if (po.NumArgs() < 2 || po.NumArgs() > 3) {
    55     if (po.NumArgs() == 2) {
    56       std::string ivector_rspecifier = po.GetArg(1),
    57           ivector_wspecifier = po.GetArg(2);
    61       std::vector<std::pair<std::string, Vector<BaseFloat>*> > ivectors;
    67       for (; !ivector_reader.Done(); ivector_reader.Next()) {
    68         std::string key = ivector_reader.Key();
    76       KALDI_LOG << 
"Read " << num_done << 
" iVectors.";
    79         KALDI_LOG << 
"Norm of iVector mean was " << (sum.
Norm(2.0) / num_done);
    80         for (
size_t i = 0; 
i < ivectors.size(); 
i++) {
    81           std::string key = ivectors[
i].first;
    84             ivector->
AddVec(-1.0 / num_done, sum);
    85           ivector_writer.Write(key, *ivector);
    87           ivectors[
i].second = NULL;
    92       std::string mean_rxfilename = po.GetArg(1),
    93           ivector_rspecifier = po.GetArg(2),
    94           ivector_wspecifier = po.GetArg(3);
   100       for (; !ivector_reader.Done(); ivector_reader.Next()) {
   101         std::string key = ivector_reader.Key();
   103         ivector.
AddVec(-1.0, mean);
   104         ivector_writer.Write(key, ivector);
   108     KALDI_LOG << 
"Wrote " << num_done << 
" mean-subtracted iVectors";
   109     return (num_done != 0 ? 0 : 1);
   111   } 
catch(
const std::exception &e) {
   112     std::cerr << e.what();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
A templated class for writing objects to an archive or script file; see The Table concept...
 
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero). 
 
Real Norm(Real p) const
Compute the p-th norm of the vector. 
 
void ReadKaldiObject(const std::string &filename, Matrix< float > *m)
 
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...
 
MatrixIndexT Dim() const
Returns the dimension of the vector. 
 
void AddVec(const Real alpha, const VectorBase< OtherReal > &v)
Add vector : *this = *this + alpha * rv (with casting between floats and doubles) ...