facebookresearch / WavAugment

A library for speech data augmentation in time-domain
MIT License
640 stars 57 forks source link

Use torchaudio for sox effects #16

Closed vincentqb closed 3 years ago

vincentqb commented 3 years ago

As mentioned in #14, here's a pull request migrating WavAugment to torchaudio 0.7 :) This replaces the C++ backend with torchaudio.

❯ python -m pytest -v --doctest-modules
=============================================================================================================== test session starts ================================================================================================================
platform linux -- Python 3.8.6, pytest-6.1.1, py-1.9.0, pluggy-0.13.1 -- /private/home/vincentqb/anaconda3/envs/wavaugment/bin/python
cachedir: .pytest_cache
rootdir: /private/home/vincentqb/WavAugment
collected 14 items                                                                                                                                                                                                                                 

augment/effects.py::augment.effects.EffectChain PASSED                                                                                                                                                                                       [  7%]
augment/effects.py::augment.effects.EffectChain.additive_noise PASSED                                                                                                                                                                        [ 14%]
augment/effects.py::augment.effects.EffectChain.clip PASSED                                                                                                                                                                                  [ 21%]
augment/effects.py::augment.effects.EffectChain.time_dropout PASSED                                                                                                                                                                          [ 28%]
augment/effects.py::augment.effects.SoxEffect.instantiate PASSED                                                                                                                                                                             [ 35%]
tests/augment_test.py::test_empty_chain PASSED                                                                                                                                                                                               [ 42%]
tests/augment_test.py::test_non_empty_chain PASSED                                                                                                                                                                                           [ 50%]
tests/augment_test.py::test_agains_cl PASSED                                                                                                                                                                                                 [ 57%]
tests/augment_test.py::test_stochastic_pitch PASSED                                                                                                                                                                                          [ 64%]
tests/augment_test.py::test_additive_noise PASSED                                                                                                                                                                                            [ 71%]
tests/augment_test.py::test_number_effects PASSED                                                                                                                                                                                            [ 78%]
tests/compare_to_sox_test.py::test_pitch PASSED                                                                                                                                                                                              [ 85%]
tests/compare_to_sox_test.py::test_reverb PASSED                                                                                                                                                                                             [ 92%]
tests/compare_to_sox_test.py::test_bandreject PASSED                                                                                                                                                                                         [100%]

================================================================================================================= warnings summary =================================================================================================================
../anaconda3/envs/wavaugment/lib/python3.8/site-packages/torchaudio/backend/utils.py:53
  /private/home/vincentqb/anaconda3/envs/wavaugment/lib/python3.8/site-packages/torchaudio/backend/utils.py:53: UserWarning: "sox" backend is being deprecated. The default backend will be changed to "sox_io" backend in 0.8.0 and "sox" backend will be removed in 0.9.0. Please migrate to "sox_io" backend. Please refer to https://github.com/pytorch/audio/issues/903 for the detail.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================================================== 14 passed, 1 warning in 1.34s ===========================================================================================================

Thoughts?

Closes #14

cc @eugene-kharitonov @astaff

vincentqb commented 3 years ago

BTW the warning simply means that torchaudio.set_audio_backend("sox_io") is the default on master and will be the default in the next release.

eugene-kharitonov commented 3 years ago

Cool, thanks a lot @vincentqb ! I'll check this out in the next few days :)

vincentqb commented 3 years ago

yay for the approval :)