From 71ef9c20e3523b77d0badf4790eeeb793d9644e1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 3 Mar 2013 15:33:29 -0500 Subject: [PATCH] python/tests/test_filterbank.py: added test against existing coeffs --- .../tests/filterbank_mfcc_16000_512.expected | 0 python/tests/test_filterbank.py | 11 +++++++++++ 2 files changed, 11 insertions(+) rename tests/python/src/spectral/filterbank_mfcc_16000_512.txt => python/tests/filterbank_mfcc_16000_512.expected (100%) diff --git a/tests/python/src/spectral/filterbank_mfcc_16000_512.txt b/python/tests/filterbank_mfcc_16000_512.expected similarity index 100% rename from tests/python/src/spectral/filterbank_mfcc_16000_512.txt rename to python/tests/filterbank_mfcc_16000_512.expected diff --git a/python/tests/test_filterbank.py b/python/tests/test_filterbank.py index 595d022a..3fd64fd9 100755 --- a/python/tests/test_filterbank.py +++ b/python/tests/test_filterbank.py @@ -4,8 +4,13 @@ from numpy.testing import TestCase, run_module_suite from numpy.testing import assert_equal, assert_almost_equal from numpy import random from math import pi +from numpy import array from aubio import cvec, filterbank +def array_from_text_file(filename, dtype = 'float'): + return array([line.split() for line in open(filename).readlines()], + dtype = dtype) + class aubio_filterbank_test_case(TestCase): def test_members(self): @@ -54,6 +59,12 @@ class aubio_filterbank_test_case(TestCase): assert_equal ( f(c) < 1., True ) assert_equal ( f(c) > 0., True ) + def test_mfcc_coeffs_16000(self): + expected = array_from_text_file('filterbank_mfcc_16000_512.expected') + f = filterbank(40, 512) + f.set_mel_coeffs_slaney(16000) + assert_almost_equal ( expected, f.get_coeffs() ) + if __name__ == '__main__': from unittest import main main() -- 2.26.2