From 06b26fbf8e21cb4cea0f10de28ddfe43e6b09c9d Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 4 Jan 2024 12:35:45 +0800 Subject: [PATCH] Use high_freq -400 in computing fbank features. Fixes #514 --- sherpa-onnx/csrc/features.cc | 6 ++++++ sherpa-onnx/csrc/offline-stream.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sherpa-onnx/csrc/features.cc b/sherpa-onnx/csrc/features.cc index 51500e116..e81c0dfb4 100644 --- a/sherpa-onnx/csrc/features.cc +++ b/sherpa-onnx/csrc/features.cc @@ -46,6 +46,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-onnx/csrc/offline-stream.cc b/sherpa-onnx/csrc/offline-stream.cc index 3cb463b49..08e601363 100644 --- a/sherpa-onnx/csrc/offline-stream.cc +++ b/sherpa-onnx/csrc/offline-stream.cc @@ -83,6 +83,12 @@ class OfflineStream::Impl { opts_.frame_opts.samp_freq = config.sampling_rate; 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_); }