def test_feature_extractor(feature_type, exception_expectation): # For now, just test that it runs # TODO: test that the output is similar to Kaldi with exception_expectation: fe = FeatureExtractor(type=feature_type) samples, sr = torchaudio.load( 'test/fixtures/libri/libri-1088-134315-0000.wav') fe.extract(samples=samples, sampling_rate=sr)
def test_overlay_fbank(): # Treat it more like a test of "it runs" rather than "it works" t = np.linspace(0, 1, 8000, dtype=np.float32) x1 = np.sin(440.0 * t).reshape(1, -1) x2 = np.sin(55.0 * t).reshape(1, -1) feature_extractor = FeatureExtractor(type='fbank') f1 = feature_extractor.extract(x1, 8000).numpy() f2 = feature_extractor.extract(x2, 8000).numpy() mixer = FbankMixer( base_feats=f1, frame_shift=feature_extractor.spectrogram_config.frame_shift, ) mixer.add_to_mix(f2) fmix_feat = mixer.mixed_feats fmix_time = feature_extractor.extract(x1 + x2, 8000).numpy() np.testing.assert_almost_equal(fmix_feat, fmix_time, decimal=0)