|
1 | 1 | import os |
2 | 2 | from functools import lru_cache |
3 | 3 | from typing import BinaryIO, Dict, Optional, Tuple, Type, Union |
| 4 | +import warnings |
4 | 5 |
|
5 | 6 | import torch |
6 | 7 |
|
@@ -127,6 +128,14 @@ def load( |
127 | 128 | ) -> Tuple[torch.Tensor, int]: |
128 | 129 | """Load audio data from source. |
129 | 130 |
|
| 131 | + .. warning:: |
| 132 | + In 2.9, this function's implementation will be changed to use |
| 133 | + :func:`~torchaudio.load_with_torchcodec` under the hood. Some |
| 134 | + parameters like ``normalize``, ``format``, ``buffer_size``, and |
| 135 | + ``backend`` will be ignored. We recommend that you port your code to |
| 136 | + rely directly on TorchCodec's decoder instead: |
| 137 | + https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.decoders.AudioDecoder.html#torchcodec.decoders.AudioDecoder. |
| 138 | +
|
130 | 139 | By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with |
131 | 140 | ``float32`` dtype, and the shape of `[channel, time]`. |
132 | 141 |
|
@@ -201,6 +210,14 @@ def load( |
201 | 210 | integer type, else ``float32`` type. If ``channels_first=True``, it has |
202 | 211 | `[channel, time]` else `[time, channel]`. |
203 | 212 | """ |
| 213 | + warnings.warn( |
| 214 | + "In 2.9, this function's implementation will be changed to use " |
| 215 | + "torchaudio.load_with_torchcodec` under the hood. Some " |
| 216 | + "parameters like ``normalize``, ``format``, ``buffer_size``, and " |
| 217 | + "``backend`` will be ignored. We recommend that you port your code to " |
| 218 | + "rely directly on TorchCodec's decoder instead: " |
| 219 | + "https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.decoders.AudioDecoder.html#torchcodec.decoders.AudioDecoder." |
| 220 | + ) |
204 | 221 | backend = dispatcher(uri, format, backend) |
205 | 222 | return backend.load(uri, frame_offset, num_frames, normalize, channels_first, format, buffer_size) |
206 | 223 |
|
@@ -235,6 +252,14 @@ def save( |
235 | 252 | ): |
236 | 253 | """Save audio data to file. |
237 | 254 |
|
| 255 | + .. warning:: |
| 256 | + In 2.9, this function's implementation will be changed to use |
| 257 | + :func:`~torchaudio.save_with_torchcodec` under the hood. Some |
| 258 | + parameters like format, encoding, bits_per_sample, buffer_size, and |
| 259 | + ``backend`` will be ignored. We recommend that you port your code to |
| 260 | + rely directly on TorchCodec's decoder instead: |
| 261 | + https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.encoders.AudioEncoder |
| 262 | +
|
238 | 263 | Note: |
239 | 264 | The formats this function can handle depend on the availability of backends. |
240 | 265 | Please use the following functions to fetch the supported formats. |
@@ -309,6 +334,14 @@ def save( |
309 | 334 | Refer to http://sox.sourceforge.net/soxformat.html for more details. |
310 | 335 |
|
311 | 336 | """ |
| 337 | + warnings.warn( |
| 338 | + "In 2.9, this function's implementation will be changed to use " |
| 339 | + "torchaudio.save_with_torchcodec` under the hood. Some " |
| 340 | + "parameters like format, encoding, bits_per_sample, buffer_size, and " |
| 341 | + "``backend`` will be ignored. We recommend that you port your code to " |
| 342 | + "rely directly on TorchCodec's encoder instead: " |
| 343 | + "https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.encoders.AudioEncoder" |
| 344 | + ) |
312 | 345 | backend = dispatcher(uri, format, backend) |
313 | 346 | return backend.save( |
314 | 347 | uri, src, sample_rate, channels_first, format, encoding, bits_per_sample, buffer_size, compression |
|
0 commit comments