File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ void OnlineIvectorExtractionInfo::Init(
6767 this ->Check ();
6868}
6969
70+ int32 OnlineIvectorExtractionInfo::ExpectedFeatureDim () const {
71+ int32 num_splice = 1 + splice_opts.left_context + splice_opts.right_context ,
72+ full_dim = lda_mat.NumCols ();
73+ if (!(full_dim % num_splice == 0 || full_dim % num_splice == 1 )){
74+ KALDI_WARN << " Error getting expected feature dimension: full-dim = "
75+ << full_dim << " , num-splice = " << num_splice;
76+ }
77+ return full_dim / num_splice;
78+ }
7079
7180void OnlineIvectorExtractionInfo::Check () const {
7281 KALDI_ASSERT (global_cmvn_stats.NumRows () == 2 );
Original file line number Diff line number Diff line change @@ -194,6 +194,8 @@ struct OnlineIvectorExtractionInfo {
194194
195195 void Init (const OnlineIvectorExtractionConfig &config);
196196
197+ int32 ExpectedFeatureDim () const ;
198+
197199 // This constructor creates a version of this object where everything
198200 // is empty or zero.
199201 OnlineIvectorExtractionInfo ();
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ int main(int argc, char *argv[]) {
9494 RandomAccessBaseFloatVectorReader frame_weights_reader (frame_weights_rspecifier);
9595 BaseFloatMatrixWriter ivector_writer (ivectors_wspecifier);
9696
97+ bool warned_dim = false ;
9798 for (; !spk2utt_reader.Done (); spk2utt_reader.Next ()) {
9899 std::string spk = spk2utt_reader.Key ();
99100 const std::vector<std::string> &uttlist = spk2utt_reader.Value ();
@@ -108,7 +109,18 @@ int main(int argc, char *argv[]) {
108109 }
109110 const Matrix<BaseFloat> &feats = feature_reader.Value (utt);
110111
111- OnlineMatrixFeature matrix_feature (feats);
112+ int32 feat_dim = feats.NumCols ();
113+ if (feat_dim == ivector_info.ExpectedFeatureDim () + 3 ) {
114+ if (!warned_dim) {
115+ KALDI_WARN << " Feature dimension is too large by 3, assuming there are "
116+ " pitch features and removing the last 3 dims." ;
117+ warned_dim = true ;
118+ }
119+ feat_dim -= 3 ;
120+ }
121+
122+ SubMatrix<BaseFloat> range = feats.ColRange (0 , feat_dim);
123+ OnlineMatrixFeature matrix_feature (range);
112124
113125 OnlineIvectorFeature ivector_feature (ivector_info,
114126 &matrix_feature);
You can’t perform that action at this time.
0 commit comments