Changeset a95b386 for python/tests/test_filterbank_mel.py
- Timestamp:
- Nov 17, 2018, 4:38:29 PM (5 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- ab8e838
- Parents:
- 75f9fff (diff), 2eb52bd (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
r75f9fff ra95b386 110 110 111 111 112 def test_triangle_freqs_without_norm(self): 113 """make sure set_triangle_bands works without """ 114 samplerate = 22050 115 freq_list = fvec([0, 100, 1000, 10000]) 116 f = filterbank(len(freq_list) - 2, 1024) 117 f.set_norm(0) 118 f.set_triangle_bands(freq_list, samplerate) 119 expected = f.get_coeffs() 120 f.set_norm(1) 121 f.set_triangle_bands(fvec(freq_list), samplerate) 122 assert_almost_equal(f.get_coeffs().T, 123 expected.T * 2. / (freq_list[2:] - freq_list[:-2])) 124 125 def test_triangle_freqs_wrong_norm(self): 126 f = filterbank(10, 1024) 127 with self.assertRaises(ValueError): 128 f.set_norm(-1) 129 130 def test_triangle_freqs_with_power(self): 131 f = filterbank(9, 1024) 132 freqs = fvec([40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 133 24000]) 134 f.set_power(2) 135 f.set_triangle_bands(freqs, 48000) 136 spec = cvec(1024) 137 spec.norm[:] = .1 138 expected = fvec([0.02070313, 0.02138672, 0.02127604, 0.02135417, 139 0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345]) 140 expected /= 100. 141 assert_almost_equal(f(spec), expected) 142 143 def test_mel_coeffs(self): 144 f = filterbank(40, 1024) 145 f.set_mel_coeffs(44100, 0, 44100 / 2) 146 147 def test_zero_fmax(self): 148 f = filterbank(40, 1024) 149 f.set_mel_coeffs(44100, 0, 0) 150 151 def test_wrong_mel_coeffs(self): 152 f = filterbank(40, 1024) 153 with self.assertRaises(ValueError): 154 f.set_mel_coeffs_slaney(0) 155 with self.assertRaises(ValueError): 156 f.set_mel_coeffs(44100, 0, -44100 / 2) 157 with self.assertRaises(ValueError): 158 f.set_mel_coeffs(44100, -0.1, 44100 / 2) 159 with self.assertRaises(ValueError): 160 f.set_mel_coeffs(-44100, 0.1, 44100 / 2) 161 with self.assertRaises(ValueError): 162 f.set_mel_coeffs_htk(-1, 0, 0) 163 164 def test_mel_coeffs_htk(self): 165 f = filterbank(40, 1024) 166 f.set_mel_coeffs_htk(44100, 0, 44100 / 2) 167 168 112 169 if __name__ == '__main__': 113 170 from unittest import main
Note: See TracChangeset
for help on using the changeset viewer.