From eef3ef50bec6318a386191b3c096984b9ca6869a Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 23 Feb 2024 16:21:49 +0800 Subject: [PATCH] set default values for FeatureConfig in Python (#498) --- CMakeLists.txt | 1 + sherpa/python/csrc/feature-config.cc | 8 ++++++++ sherpa/python/csrc/sherpa.cc | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8872705cd..7bf9183cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.") endif() + set(CMAKE_CXX_EXTENSIONS OFF) option(SHERPA_ENABLE_TESTS "Whether to build tests" OFF) diff --git a/sherpa/python/csrc/feature-config.cc b/sherpa/python/csrc/feature-config.cc index c4acd9746..767e949bd 100644 --- a/sherpa/python/csrc/feature-config.cc +++ b/sherpa/python/csrc/feature-config.cc @@ -37,6 +37,14 @@ void PybindFeatureConfig(py::module &m) { // NOLINT config->normalize_samples = normalize_samples; config->nemo_normalize = nemo_normalize; + config->fbank_opts.frame_opts.dither = 0; + config->fbank_opts.mel_opts.num_bins = 80; + config->fbank_opts.mel_opts.high_freq = -400; + config->fbank_opts.frame_opts.remove_dc_offset = true; + config->fbank_opts.frame_opts.round_to_power_of_two = true; + config->fbank_opts.energy_floor = 1e-10; + config->fbank_opts.frame_opts.snip_edges = false; + config->fbank_opts.frame_opts.samp_freq = 16000; return config; }), diff --git a/sherpa/python/csrc/sherpa.cc b/sherpa/python/csrc/sherpa.cc index b4c85cf4c..2d2dd5f5a 100644 --- a/sherpa/python/csrc/sherpa.cc +++ b/sherpa/python/csrc/sherpa.cc @@ -21,8 +21,6 @@ #include #include "sherpa/csrc/version.h" -#include "sherpa/python/csrc/resample.h" -// #include "sherpa/python/csrc/endpoint.h" #include "sherpa/python/csrc/fast-beam-search-config.h" #include "sherpa/python/csrc/feature-config.h" @@ -31,12 +29,16 @@ #include "sherpa/python/csrc/offline-stream.h" #include "sherpa/python/csrc/online-recognizer.h" #include "sherpa/python/csrc/online-stream.h" +#include "sherpa/python/csrc/resample.h" namespace sherpa { PYBIND11_MODULE(_sherpa, m) { m.doc() = "pybind11 binding of sherpa"; m.attr("cxx_flags") = std::string(kCMakeCxxFlags); + auto torch = py::module::import("torch"); + auto kaldifeat = py::module::import("_kaldifeat"); + (void)kaldifeat.attr("FbankOptions"); PybindResample(m);