From d615bff04c96afad1f41a72d3a974b12943ff61b Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 4 Jan 2024 13:56:16 +0800 Subject: [PATCH] Use high_freq -400 in computing fbank features. (#294) * Use high_freq -400 in computing fbank features. See also https://github.com/k2-fsa/sherpa-onnx/issues/514 * Release v2.1.5 --- CMakeLists.txt | 2 +- sherpa-ncnn/csrc/features.cc | 6 ++++++ sherpa-ncnn/csrc/generate-int8-scale-table.cc | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b12938c4..7e9b36b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(sherpa-ncnn) -set(SHERPA_NCNN_VERSION "2.1.4") +set(SHERPA_NCNN_VERSION "2.1.5") # Disable warning about # diff --git a/sherpa-ncnn/csrc/features.cc b/sherpa-ncnn/csrc/features.cc index 0c082f07..b0328f6a 100644 --- a/sherpa-ncnn/csrc/features.cc +++ b/sherpa-ncnn/csrc/features.cc @@ -48,6 +48,12 @@ class FeatureExtractor::Impl { opts_.mel_opts.num_bins = config.feature_dim; + // Please see + // https://github.com/lhotse-speech/lhotse/blob/master/lhotse/features/fbank.py#L27 + // and + // https://github.com/k2-fsa/sherpa-onnx/issues/514 + opts_.mel_opts.high_freq = -400; + fbank_ = std::make_unique(opts_); } diff --git a/sherpa-ncnn/csrc/generate-int8-scale-table.cc b/sherpa-ncnn/csrc/generate-int8-scale-table.cc index 07934d85..82b43af6 100644 --- a/sherpa-ncnn/csrc/generate-int8-scale-table.cc +++ b/sherpa-ncnn/csrc/generate-int8-scale-table.cc @@ -560,6 +560,12 @@ int QuantNet::quantize_KL(const std::vector &wave_filenames) { fbank_opts.frame_opts.samp_freq = expected_sampling_rate; fbank_opts.mel_opts.num_bins = 80; + // Please see + // https://github.com/lhotse-speech/lhotse/blob/master/lhotse/features/fbank.py#L27 + // and + // https://github.com/k2-fsa/sherpa-onnx/issues/514 + fbank_opts.mel_opts.high_freq = -400; + int32_t segment = model->Segment(); int32_t offset = model->Offset();