Changeset f264b17 for python/tests/test_filterbank_mel.py
- Timestamp:
- Jun 22, 2016, 1:00:10 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 4b9443c4
- Parents:
- 60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_filterbank_mel.py
r60fc05b rf264b17 1 1 #! /usr/bin/env python 2 2 3 from numpy.testing import TestCase, run_module_suite 3 from unittest import main 4 from numpy.testing import TestCase 4 5 from numpy.testing import assert_equal, assert_almost_equal 5 6 from numpy import array, shape 6 from aubio import cvec, filterbank 7 from aubio import cvec, filterbank, float_type 7 8 8 9 class aubio_filterbank_mel_test_case(TestCase): 9 10 10 def test_slaney(self):11 f = filterbank(40, 512)12 f.set_mel_coeffs_slaney(16000)13 a = f.get_coeffs()14 assert_equal(shape (a), (40, 512/2 + 1) )11 def test_slaney(self): 12 f = filterbank(40, 512) 13 f.set_mel_coeffs_slaney(16000) 14 a = f.get_coeffs() 15 assert_equal(shape (a), (40, 512/2 + 1) ) 15 16 16 def test_other_slaney(self):17 f = filterbank(40, 512*2)18 f.set_mel_coeffs_slaney(44100)19 a= f.get_coeffs()20 #print "sum is", sum(sum(a))21 for win_s in [256, 512, 1024, 2048, 4096]:22 f = filterbank(40, win_s)23 f.set_mel_coeffs_slaney(320000)24 a= f.get_coeffs()25 #print "sum is", sum(sum(a))17 def test_other_slaney(self): 18 f = filterbank(40, 512*2) 19 f.set_mel_coeffs_slaney(44100) 20 _ = f.get_coeffs() 21 #print "sum is", sum(sum(a)) 22 for win_s in [256, 512, 1024, 2048, 4096]: 23 f = filterbank(40, win_s) 24 f.set_mel_coeffs_slaney(32000) 25 _ = f.get_coeffs() 26 #print "sum is", sum(sum(a)) 26 27 27 def test_triangle_freqs_zeros(self):28 f = filterbank(9, 1024)29 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]30 freqs = array(freq_list, dtype = 'float32')31 f.set_triangle_bands(freqs, 48000)32 f.get_coeffs().T33 assert_equal ( f(cvec(1024)), 0)28 def test_triangle_freqs_zeros(self): 29 f = filterbank(9, 1024) 30 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 31 freqs = array(freq_list, dtype = float_type) 32 f.set_triangle_bands(freqs, 48000) 33 _ = f.get_coeffs().T 34 assert_equal ( f(cvec(1024)), 0) 34 35 35 def test_triangle_freqs_ones(self):36 f = filterbank(9, 1024)37 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]38 freqs = array(freq_list, dtype = 'float32')39 f.set_triangle_bands(freqs, 48000)40 f.get_coeffs().T41 spec = cvec(1024)42 spec.norm[:] = 143 assert_almost_equal ( f(spec),44 [ 0.02070313, 0.02138672, 0.02127604, 0.02135417,45 0.02133301, 0.02133301, 0.02133311, 0.02133334,0.02133345])36 def test_triangle_freqs_ones(self): 37 f = filterbank(9, 1024) 38 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 39 freqs = array(freq_list, dtype = float_type) 40 f.set_triangle_bands(freqs, 48000) 41 _ = f.get_coeffs().T 42 spec = cvec(1024) 43 spec.norm[:] = 1 44 assert_almost_equal ( f(spec), 45 [ 0.02070313, 0.02138672, 0.02127604, 0.02135417, 46 0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345]) 46 47 47 48 if __name__ == '__main__': 48 from unittest import main 49 main() 50 51 49 main()
Note: See TracChangeset
for help on using the changeset viewer.