Esempio n. 1
0
def test_check_sampling_rate():
    dataset_path = './tests/data'
    dataset = Dataset(dataset_path)
    sr = 22050
    audio_path_sr = dataset.get_audio_paths(sr)[1][0]
    _clean(audio_path_sr)
    dataset.change_sampling_rate(sr)
    assert dataset.check_sampling_rate(sr)
Esempio n. 2
0
def test_change_sampling_rate(sr):
    dataset_path = './tests/data'
    dataset = Dataset(dataset_path)
    audio_path = dataset.get_audio_paths()[0]
    audio_path_sr = dataset.get_audio_paths(sr)[1][0]
    _clean(audio_path_sr)
    dataset.change_sampling_rate(sr)
    for file_audio in audio_files:
        file_path = os.path.join(audio_path_sr, file_audio)
        file_data, file_sr = sf.read(file_path)
        length_seconds = len(file_data) / float(file_sr)

        file_path_original = os.path.join(audio_path, file_audio)
        file_data_original, file_sr_original = sf.read(file_path_original)
        length_seconds_original = len(file_data_original) / \
            float(file_sr_original)

        assert np.allclose(length_seconds,
                           length_seconds_original,
                           rtol=0.0001,
                           atol=0.0001)

    assert dataset.check_sampling_rate(sr)