Skip to content

Commit

Permalink
Update apply_codec to use dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed May 31, 2023
1 parent c5d3706 commit 0410f2b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions torchaudio/functional/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,12 +1322,12 @@ def apply_codec(
Tensor: Resulting Tensor.
If ``channels_first=True``, it has `(channel, time)` else `(time, channel)`.
"""
torchaudio.utils.ffmpeg_utils.set_log_level(56)
bytes = io.BytesIO()
torchaudio.backend.sox_io_backend.save(
bytes, waveform, sample_rate, channels_first, compression, format, encoding, bits_per_sample
)
torchaudio.save(
bytes, waveform, sample_rate, channels_first=channels_first, format=format, encoding=encoding, bits_per_sample=bits_per_sample)
bytes.seek(0)
augmented, sr = torchaudio.backend.sox_io_backend.load(bytes, channels_first=channels_first, format=format)
augmented, sr = torchaudio.load(bytes, channels_first=channels_first, format=format)
if sr != sample_rate:
augmented = resample(augmented, sr, sample_rate)
return augmented
Expand Down

0 comments on commit 0410f2b

Please sign in to comment.