Skip to content

Commit

Permalink
stretch and then resample
Browse files Browse the repository at this point in the history
  • Loading branch information
KentoNishi committed Aug 4, 2021
1 parent 3ee4177 commit 1305f57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch_pitch_shift/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def pitch_shift(
resampler = T.Resample(sample_rate, int(sample_rate / shift)).to(input.device)
output = input
output = output.reshape(batch_size * channels, samples)
output = resampler(output)
output = torch.stft(output, n_fft)[None, ...]
stretcher = T.TimeStretch(fixed_rate=float(1 / shift), n_freq=output.shape[2]).to(
input.device
)
output = stretcher(output)
output = torch.istft(output[0], n_fft)
output = resampler(output)
del resampler, stretcher
if output.shape[1] >= input.shape[2]:
output = output[:, : (input.shape[2])]
Expand Down

0 comments on commit 1305f57

Please sign in to comment.