Skip to content

Commit

Permalink
set default values for FeatureConfig in Python (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Feb 23, 2024
1 parent 77b6367 commit eef3ef5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions sherpa/python/csrc/feature-config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}),
Expand Down
6 changes: 4 additions & 2 deletions sherpa/python/csrc/sherpa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <string>

#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"
Expand All @@ -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);

Expand Down

0 comments on commit eef3ef5

Please sign in to comment.