Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Added simple test for mel-filterbank creation
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-nervana authored and apark263 committed Nov 2, 2016
1 parent 7160cd6 commit 82d92ce
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions loader/test/test_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,25 @@ TEST(etl, sox_use) {
}

}


TEST(audio, filterbank) {

int sample_rate = 2000;
int fftsz = 20;
int num_filters = 1;

// Computed using python
float expected[11] = {0., 0.25, 0.5, 0.75, 1., 5. / 6, 2. / 3, 0.5, 1. / 3, 1. / 6, 0.};

cv::Mat fbank;
specgram::create_filterbanks(num_filters, fftsz, sample_rate, fbank);
ASSERT_EQ(11, fbank.rows);
ASSERT_EQ(1, fbank.cols);

for (int ii = 0; ii < 11; ++ii) {
ASSERT_NEAR(expected[ii], fbank.at<float>(ii, 0), 1e-6);
}

}

0 comments on commit 82d92ce

Please sign in to comment.