Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/scripts/unittest-linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ case $GPU_ARCH_TYPE in
esac
PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/${UPLOAD_CHANNEL}/${GPU_ARCH_ID}"
pip install --progress-bar=off --pre torch --index-url="${PYTORCH_WHEEL_INDEX}"
pip install --progress-bar=off --pre torchcodec --index-url="https://download.pytorch.org/whl/nightly/cpu"


# 2. Install torchaudio
Expand All @@ -86,6 +87,10 @@ python setup.py install

# 3. Install Test tools
printf "* Installing test tools\n"
# On this CI, for whatever reason, we're only able to install ffmpeg 4.
conda install -y "ffmpeg<5"
python -c "import torch; import torchaudio; import torchcodec; print(torch.__version__, torchaudio.__version__, torchcodec.__version__)"

NUMBA_DEV_CHANNEL=""
if [[ "$(python --version)" = *3.9* || "$(python --version)" = *3.10* ]]; then
# Numba isn't available for Python 3.9 and 3.10 except on the numba dev channel and building from source fails
Expand All @@ -94,7 +99,7 @@ if [[ "$(python --version)" = *3.9* || "$(python --version)" = *3.10* ]]; then
fi
(
set -x
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} sox libvorbis parameterized 'requests>=2.20' 'ffmpeg>=6,<7'
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} sox libvorbis parameterized 'requests>=2.20'
pip install kaldi-io SoundFile librosa coverage pytest pytest-cov scipy expecttest unidecode inflect Pillow sentencepiece pytorch-lightning 'protobuf<4.21.0' demucs tinytag pyroomacoustics flashlight-text git+https://github.com/kpu/kenlm

# TODO: might be better to fix the single call to `pip install` above
Expand Down
10 changes: 8 additions & 2 deletions docs/source/torchaudio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ torchaudio
Starting with version 2.8, we are refactoring TorchAudio to transition it
into a maintenance phase. As a result:

- The APIs listed below are deprecated in 2.8 and will be removed in 2.9.
- Most APIs listed below are deprecated in 2.8 and will be removed in 2.9.
- The decoding and encoding capabilities of PyTorch for both audio and video
are being consolidated into TorchCodec.
are being consolidated into TorchCodec. For convenience, we provide
:func:`~torchaudio.load_with_torchcodec` as a replacement for
:func:`~torchaudio.load` and :func:`~torchaudio.save_with_torchcodec` as a
replacement for :func:`~torchaudio.save`, but we recommend that you port
your code to native torchcodec APIs.

Please see https://github.com/pytorch/audio/issues/3902 for more information.

Expand All @@ -26,7 +30,9 @@ it easy to handle audio data.

info
load
load_with_torchcodec
save
save_with_torchcodec
list_audio_backends

.. _backend:
Expand Down
9 changes: 5 additions & 4 deletions src/torchaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
get_audio_backend as _get_audio_backend,
info as _info,
list_audio_backends as _list_audio_backends,
load as _load,
save as _save,
load,
save,
set_audio_backend as _set_audio_backend,
)
from ._torchcodec import load_with_torchcodec, save_with_torchcodec

AudioMetaData = dropping_class_io_support(_AudioMetaData)
get_audio_backend = dropping_io_support(_get_audio_backend)
info = dropping_io_support(_info)
list_audio_backends = dropping_io_support(_list_audio_backends)
load = dropping_io_support(_load)
save = dropping_io_support(_save)
set_audio_backend = dropping_io_support(_set_audio_backend)

from . import ( # noqa: F401
Expand Down Expand Up @@ -45,6 +44,8 @@
__all__ = [
"AudioMetaData",
"load",
"load_with_torchcodec",
"save_with_torchcodec",
"info",
"save",
"io",
Expand Down
33 changes: 33 additions & 0 deletions src/torchaudio/_backend/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from functools import lru_cache
from typing import BinaryIO, Dict, Optional, Tuple, Type, Union
import warnings

import torch

Expand Down Expand Up @@ -127,6 +128,14 @@ def load(
) -> Tuple[torch.Tensor, int]:
"""Load audio data from source.

.. warning::
In 2.9, this function's implementation will be changed to use
:func:`~torchaudio.load_with_torchcodec` under the hood. Some
parameters like ``normalize``, ``format``, ``buffer_size``, and
``backend`` will be ignored. We recommend that you port your code to
rely directly on TorchCodec's decoder instead:
https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.decoders.AudioDecoder.html#torchcodec.decoders.AudioDecoder.

By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with
``float32`` dtype, and the shape of `[channel, time]`.

Expand Down Expand Up @@ -201,6 +210,14 @@ def load(
integer type, else ``float32`` type. If ``channels_first=True``, it has
`[channel, time]` else `[time, channel]`.
"""
warnings.warn(
"In 2.9, this function's implementation will be changed to use "
"torchaudio.load_with_torchcodec` under the hood. Some "
"parameters like ``normalize``, ``format``, ``buffer_size``, and "
"``backend`` will be ignored. We recommend that you port your code to "
"rely directly on TorchCodec's decoder instead: "
"https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.decoders.AudioDecoder.html#torchcodec.decoders.AudioDecoder."
)
backend = dispatcher(uri, format, backend)
return backend.load(uri, frame_offset, num_frames, normalize, channels_first, format, buffer_size)

Expand Down Expand Up @@ -235,6 +252,14 @@ def save(
):
"""Save audio data to file.

.. warning::
In 2.9, this function's implementation will be changed to use
:func:`~torchaudio.save_with_torchcodec` under the hood. Some
parameters like format, encoding, bits_per_sample, buffer_size, and
``backend`` will be ignored. We recommend that you port your code to
rely directly on TorchCodec's decoder instead:
https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.encoders.AudioEncoder

Note:
The formats this function can handle depend on the availability of backends.
Please use the following functions to fetch the supported formats.
Expand Down Expand Up @@ -309,6 +334,14 @@ def save(
Refer to http://sox.sourceforge.net/soxformat.html for more details.

"""
warnings.warn(
"In 2.9, this function's implementation will be changed to use "
"torchaudio.save_with_torchcodec` under the hood. Some "
"parameters like format, encoding, bits_per_sample, buffer_size, and "
"``backend`` will be ignored. We recommend that you port your code to "
"rely directly on TorchCodec's encoder instead: "
"https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.encoders.AudioEncoder"
)
backend = dispatcher(uri, format, backend)
return backend.save(
uri, src, sample_rate, channels_first, format, encoding, bits_per_sample, buffer_size, compression
Expand Down
Loading
Loading