Skip to content

Commit

Permalink
[Fbsync] Update pitch shift batch consistency test (#1700)
Browse files Browse the repository at this point in the history
* Reduce length of waveform in pitch_shift batch_consistency test

Summary: To address the test failure in T96406395

Reviewed By: carolineechen

Differential Revision: D30163741

fbshipit-source-id: f88d86b3da7b1ee52518934567b0b0a62700ee58

* Fix batch consistency test in transforms

Summary: The stress test still fails. Add n_fft to address it.

Reviewed By: mthrok

Differential Revision: D30218279

fbshipit-source-id: 7858efd3e5ac0073193a7883fd314486efc73814

Co-authored-by: Zhaoheng Ni <[email protected]>
  • Loading branch information
hwangjeff and nateanl authored Aug 12, 2021
1 parent 9c64184 commit 1a64530
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/torchaudio_unittest/transforms/batch_consistency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ def test_batch_spectral_centroid(self):

def test_batch_pitch_shift(self):
sample_rate = 8000
n_steps = 4
waveform = common_utils.get_whitenoise(sample_rate=sample_rate)
n_steps = -2
waveform = common_utils.get_whitenoise(sample_rate=sample_rate, duration=0.05)

# Single then transform then batch
expected = torchaudio.transforms.PitchShift(sample_rate, n_steps)(waveform).repeat(3, 1, 1)
expected = torchaudio.transforms.PitchShift(sample_rate, n_steps, n_fft=400)(waveform).repeat(3, 1, 1)

# Batch then transform
computed = torchaudio.transforms.PitchShift(sample_rate, n_steps)(waveform.repeat(3, 1, 1))
computed = torchaudio.transforms.PitchShift(sample_rate, n_steps, n_fft=400)(waveform.repeat(3, 1, 1))
self.assertEqual(computed, expected)

0 comments on commit 1a64530

Please sign in to comment.