From 813f4d6a266e2923ada6094a62d7142252e6a48e Mon Sep 17 00:00:00 2001 From: Yang Zhou Date: Fri, 22 Apr 2022 11:16:29 +0800 Subject: [PATCH] fix linear-spectrogram-wo-db-norm-ol feature read issue --- .../feat/linear-spectrogram-wo-db-norm-ol.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/speechx/examples/ds2_ol/feat/linear-spectrogram-wo-db-norm-ol.cc b/speechx/examples/ds2_ol/feat/linear-spectrogram-wo-db-norm-ol.cc index 0d10bd30..6f532af4 100644 --- a/speechx/examples/ds2_ol/feat/linear-spectrogram-wo-db-norm-ol.cc +++ b/speechx/examples/ds2_ol/feat/linear-spectrogram-wo-db-norm-ol.cc @@ -66,6 +66,11 @@ int main(int argc, char* argv[]) { new ppspeech::CMVN(FLAGS_cmvn_file, std::move(linear_spectrogram))); ppspeech::FeatureCacheOptions feat_cache_opts; + // the feature cache output feature chunk by chunk. + // frame_chunk_size : num frame of a chunk. + // frame_chunk_stride: chunk sliding window stride. + feat_cache_opts.frame_chunk_stride = 1; + feat_cache_opts.frame_chunk_size = 1; ppspeech::FeatureCache feature_cache(feat_cache_opts, std::move(cmvn)); LOG(INFO) << "feat dim: " << feature_cache.Dim(); @@ -105,12 +110,13 @@ int main(int argc, char* argv[]) { if (cur_chunk_size < chunk_sample_size) { feature_cache.SetFinished(); } - feature_cache.Read(&features); - if (features.Dim() == 0) break; - - feats.push_back(features); + bool flag = true; + do { + flag = feature_cache.Read(&features); + feats.push_back(features); + feature_rows += features.Dim() / feature_cache.Dim(); + } while(flag == true && features.Dim() != 0); sample_offset += cur_chunk_size; - feature_rows += features.Dim() / feature_cache.Dim(); } int cur_idx = 0;