1 Usage
<mean-rxfliename> <ivector-rspecifier> <ivector-wspecifier>
example:
ivector-subtract-global-mean mean.vec scp:ivectors.scp ark:-
2 Overview
For each ivector in ivector-rspecifier
, substract the mean vector in mean-rxfilename
, and then write it to ivector-wspecifier
.
3 Code and Comments
# read mean vector from mean.vec
Vector<BaseFloat> mean;
ReadKaldiObject(mean_rxfilename, &mean);
SequentialBaseFloatVectorReader ivector_reader(ivector_rspecifier);
BaseFloatVectorWriter ivector_writer(ivector_wspecifier);
# for each vector, substract the mean
for (; !ivector_reader.Done(); ivector_reader.Next()) {
std::string key = ivector_reader.Key();
Vector<BaseFloat> ivector = ivector_reader.Value();
ivector.AddVec(-1.0, mean);
ivector_writer.Write(key, ivector);
num_done++;
}