From e05540cfad84b91f84d0547c87e35de1f0e85c98 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sat, 14 Sep 2024 12:02:20 +0800 Subject: [PATCH] Allow all zero rows in mel computation matrix. (#107) --- CMakeLists.txt | 2 +- kaldifeat/csrc/mel-computations.cc | 10 ++++++---- scripts/conda-cpu/kaldifeat/meta.yaml | 2 +- scripts/conda/kaldifeat/meta.yaml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e936f..11f839a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(kaldifeat) # remember to change the version in # scripts/conda/kaldifeat/meta.yaml # scripts/conda-cpu/kaldifeat/meta.yaml -set(kaldifeat_VERSION "1.25.4") +set(kaldifeat_VERSION "1.25.5") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") diff --git a/kaldifeat/csrc/mel-computations.cc b/kaldifeat/csrc/mel-computations.cc index 4d9d945..6ff18aa 100644 --- a/kaldifeat/csrc/mel-computations.cc +++ b/kaldifeat/csrc/mel-computations.cc @@ -138,7 +138,7 @@ MelBanks::MelBanks(const MelBanksOptions &opts, << " and vtln-high " << vtln_high << ", versus " << "low-freq " << low_freq << " and high-freq " << high_freq; - // we will transpose bins_mat_ at the end of this funciton + // we will transpose bins_mat_ at the end of this function bins_mat_ = torch::zeros({num_bins, num_fft_bins}, torch::kFloat); int32_t stride = bins_mat_.strides()[0]; @@ -179,12 +179,14 @@ MelBanks::MelBanks(const MelBanksOptions &opts, last_index = i; } } - KALDIFEAT_ASSERT(first_index != -1 && last_index >= first_index && - "You may have set num_mel_bins too large."); + + // Note: It is possible that first_index == last_index == -1 at this line. // Replicate a bug in HTK, for testing purposes. - if (opts.htk_mode && bin == 0 && mel_low_freq != 0.0f) + if (opts.htk_mode && bin == 0 && mel_low_freq != 0.0f && + first_index != -1) { this_bin[first_index] = 0.0f; + } } if (debug_) KALDIFEAT_LOG << bins_mat_; diff --git a/scripts/conda-cpu/kaldifeat/meta.yaml b/scripts/conda-cpu/kaldifeat/meta.yaml index 18167b9..056465b 100644 --- a/scripts/conda-cpu/kaldifeat/meta.yaml +++ b/scripts/conda-cpu/kaldifeat/meta.yaml @@ -1,6 +1,6 @@ package: name: kaldifeat - version: "1.25.4" + version: "1.25.5" source: path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}" diff --git a/scripts/conda/kaldifeat/meta.yaml b/scripts/conda/kaldifeat/meta.yaml index 2bb7afe..528e942 100644 --- a/scripts/conda/kaldifeat/meta.yaml +++ b/scripts/conda/kaldifeat/meta.yaml @@ -1,6 +1,6 @@ package: name: kaldifeat - version: "1.25.4" + version: "1.25.5" source: path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"