-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from CustomProgrammingSolutions/bugfix-empty-…
…wave-features [MRG] Fix issues with feature extraction and empty wav files
- Loading branch information
Showing
4 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
def test_empty_wave(tmp_path, create_note_sequence, make_wav): | ||
"""Test that empty wav files are detected""" | ||
from persephone.preprocess.feat_extract import empty_wav | ||
wavs_dir = tmp_path / "audio" | ||
wavs_dir.mkdir() | ||
no_data = [] | ||
empty_wav_path = wavs_dir / "empty.wav" | ||
make_wav(no_data, str(empty_wav_path)) | ||
assert empty_wav(empty_wav_path) | ||
|
||
data_a_b = create_note_sequence(notes=["A","B"]) | ||
wav_test1 = wavs_dir / "test1.wav" | ||
make_wav(data_a_b, str(wav_test1)) | ||
assert not empty_wav(wav_test1) | ||
|
||
def test_empty_wave_skipped(tmp_path, make_wav): | ||
"""Test that an empty wave file will be skipped instead of crashing.""" | ||
from persephone.preprocess import feat_extract | ||
from persephone.exceptions import PersephoneException | ||
wavs_dir = tmp_path / "audio" | ||
wavs_dir.mkdir() | ||
no_data = [] | ||
empty_wav_path = wavs_dir / "empty.wav" | ||
make_wav(no_data, str(empty_wav_path)) | ||
with pytest.raises(PersephoneException): | ||
feat_extract.from_dir(wavs_dir, "fbank") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
tox | ||
pluggy>0.7 | ||
pylint>1.8 | ||
pytest | ||
pytest>=3.9 | ||
pytest-cov | ||
mypy>=0.6 |