Skip to content

Commit

Permalink
Allow all zero rows in mel computation matrix. (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Sep 14, 2024
1 parent 5f9602a commit e05540c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 6 additions & 4 deletions kaldifeat/csrc/mel-computations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion scripts/conda-cpu/kaldifeat/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: kaldifeat
version: "1.25.4"
version: "1.25.5"

source:
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/conda/kaldifeat/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: kaldifeat
version: "1.25.4"
version: "1.25.5"

source:
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
Expand Down

0 comments on commit e05540c

Please sign in to comment.