(tmpdir)
| 8 | |
| 9 | @pytest.mark.execution_timeout(10) |
| 10 | def test_preprocessing(tmpdir): |
| 11 | cmvn_ark = str(tmpdir.join("cmvn.ark")) |
| 12 | kwargs = { |
| 13 | "process": [ |
| 14 | {"type": "fbank", "n_mels": 80, "fs": 16000, "n_fft": 1024, "n_shift": 512}, |
| 15 | ], |
| 16 | "mode": "sequential", |
| 17 | } |
| 18 | |
| 19 | # Creates cmvn_ark |
| 20 | samples = np.random.randn(100, 80) |
| 21 | stats = np.empty((2, 81), dtype=np.float32) |
| 22 | stats[0, :80] = samples.sum(axis=0) |
| 23 | stats[1, :80] = (samples**2).sum(axis=0) |
| 24 | stats[0, -1] = 100.0 |
| 25 | stats[1, -1] = 0.0 |
| 26 | kaldiio.save_mat(cmvn_ark, stats) |
| 27 | |
| 28 | bs = 1 |
| 29 | xs = [np.random.randn(1000).astype(np.float32) for _ in range(bs)] |
| 30 | preprocessing = Transformation(kwargs) |
| 31 | processed_xs = preprocessing(xs) |
| 32 | |
| 33 | for idx, x in enumerate(xs): |
| 34 | opt = dict(kwargs["process"][0]) |
| 35 | opt.pop("type") |
| 36 | x = logmelspectrogram(x, **opt) |
| 37 | |
| 38 | np.testing.assert_allclose(processed_xs[idx], x) |
nothing calls this directly
no test coverage detected
searching dependent graphs…