torchaudio 2.8.0__cp313-cp313-manylinux_2_28_aarch64.whl → 2.9.0__cp313-cp313-manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of torchaudio might be problematic. Click here for more details.

Files changed (94) hide show
  1. torchaudio/__init__.py +179 -39
  2. torchaudio/_extension/__init__.py +1 -14
  3. torchaudio/_extension/utils.py +0 -47
  4. torchaudio/_internal/module_utils.py +12 -3
  5. torchaudio/_torchcodec.py +73 -85
  6. torchaudio/datasets/cmuarctic.py +1 -1
  7. torchaudio/datasets/utils.py +1 -1
  8. torchaudio/functional/__init__.py +0 -2
  9. torchaudio/functional/_alignment.py +1 -1
  10. torchaudio/functional/filtering.py +70 -55
  11. torchaudio/functional/functional.py +26 -60
  12. torchaudio/lib/_torchaudio.so +0 -0
  13. torchaudio/lib/libtorchaudio.so +0 -0
  14. torchaudio/models/decoder/__init__.py +14 -2
  15. torchaudio/models/decoder/_ctc_decoder.py +6 -6
  16. torchaudio/models/decoder/_cuda_ctc_decoder.py +1 -1
  17. torchaudio/models/squim/objective.py +2 -2
  18. torchaudio/pipelines/_source_separation_pipeline.py +1 -1
  19. torchaudio/pipelines/_squim_pipeline.py +2 -2
  20. torchaudio/pipelines/_tts/utils.py +1 -1
  21. torchaudio/pipelines/rnnt_pipeline.py +4 -4
  22. torchaudio/transforms/__init__.py +1 -0
  23. torchaudio/transforms/_transforms.py +2 -2
  24. torchaudio/utils/__init__.py +2 -9
  25. torchaudio/utils/download.py +1 -3
  26. torchaudio/version.py +2 -2
  27. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/METADATA +8 -11
  28. torchaudio-2.9.0.dist-info/RECORD +85 -0
  29. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/top_level.txt +0 -1
  30. torchaudio/_backend/__init__.py +0 -61
  31. torchaudio/_backend/backend.py +0 -53
  32. torchaudio/_backend/common.py +0 -52
  33. torchaudio/_backend/ffmpeg.py +0 -334
  34. torchaudio/_backend/soundfile.py +0 -54
  35. torchaudio/_backend/soundfile_backend.py +0 -457
  36. torchaudio/_backend/sox.py +0 -91
  37. torchaudio/_backend/utils.py +0 -350
  38. torchaudio/backend/__init__.py +0 -8
  39. torchaudio/backend/_no_backend.py +0 -25
  40. torchaudio/backend/_sox_io_backend.py +0 -294
  41. torchaudio/backend/common.py +0 -13
  42. torchaudio/backend/no_backend.py +0 -14
  43. torchaudio/backend/soundfile_backend.py +0 -14
  44. torchaudio/backend/sox_io_backend.py +0 -14
  45. torchaudio/io/__init__.py +0 -20
  46. torchaudio/io/_effector.py +0 -347
  47. torchaudio/io/_playback.py +0 -72
  48. torchaudio/kaldi_io.py +0 -150
  49. torchaudio/lib/_torchaudio_sox.so +0 -0
  50. torchaudio/lib/libtorchaudio_sox.so +0 -0
  51. torchaudio/prototype/__init__.py +0 -0
  52. torchaudio/prototype/datasets/__init__.py +0 -4
  53. torchaudio/prototype/datasets/musan.py +0 -68
  54. torchaudio/prototype/functional/__init__.py +0 -26
  55. torchaudio/prototype/functional/_dsp.py +0 -441
  56. torchaudio/prototype/functional/_rir.py +0 -382
  57. torchaudio/prototype/functional/functional.py +0 -193
  58. torchaudio/prototype/models/__init__.py +0 -39
  59. torchaudio/prototype/models/_conformer_wav2vec2.py +0 -801
  60. torchaudio/prototype/models/_emformer_hubert.py +0 -337
  61. torchaudio/prototype/models/conv_emformer.py +0 -529
  62. torchaudio/prototype/models/hifi_gan.py +0 -342
  63. torchaudio/prototype/models/rnnt.py +0 -717
  64. torchaudio/prototype/models/rnnt_decoder.py +0 -402
  65. torchaudio/prototype/pipelines/__init__.py +0 -21
  66. torchaudio/prototype/pipelines/_vggish/__init__.py +0 -7
  67. torchaudio/prototype/pipelines/_vggish/_vggish_impl.py +0 -236
  68. torchaudio/prototype/pipelines/_vggish/_vggish_pipeline.py +0 -83
  69. torchaudio/prototype/pipelines/hifigan_pipeline.py +0 -233
  70. torchaudio/prototype/pipelines/rnnt_pipeline.py +0 -58
  71. torchaudio/prototype/transforms/__init__.py +0 -9
  72. torchaudio/prototype/transforms/_transforms.py +0 -461
  73. torchaudio/sox_effects/__init__.py +0 -10
  74. torchaudio/sox_effects/sox_effects.py +0 -275
  75. torchaudio/utils/ffmpeg_utils.py +0 -11
  76. torchaudio/utils/sox_utils.py +0 -118
  77. torchaudio-2.8.0.dist-info/RECORD +0 -147
  78. torio/__init__.py +0 -8
  79. torio/_extension/__init__.py +0 -13
  80. torio/_extension/utils.py +0 -147
  81. torio/io/__init__.py +0 -9
  82. torio/io/_streaming_media_decoder.py +0 -977
  83. torio/io/_streaming_media_encoder.py +0 -502
  84. torio/lib/__init__.py +0 -0
  85. torio/lib/_torio_ffmpeg4.so +0 -0
  86. torio/lib/_torio_ffmpeg5.so +0 -0
  87. torio/lib/_torio_ffmpeg6.so +0 -0
  88. torio/lib/libtorio_ffmpeg4.so +0 -0
  89. torio/lib/libtorio_ffmpeg5.so +0 -0
  90. torio/lib/libtorio_ffmpeg6.so +0 -0
  91. torio/utils/__init__.py +0 -4
  92. torio/utils/ffmpeg_utils.py +0 -275
  93. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/LICENSE +0 -0
  94. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/WHEEL +0 -0
torchaudio/__init__.py CHANGED
@@ -1,39 +1,13 @@
1
- from torchaudio._internal.module_utils import dropping_io_support, dropping_class_io_support
1
+ import os
2
+ from typing import BinaryIO, Optional, Tuple, Union
3
+
4
+ import torch
2
5
 
3
6
  # Initialize extension and backend first
4
7
  from . import _extension # noqa # usort: skip
5
- from ._backend import ( # noqa # usort: skip
6
- AudioMetaData as _AudioMetaData,
7
- get_audio_backend as _get_audio_backend,
8
- info as _info,
9
- list_audio_backends as _list_audio_backends,
10
- load,
11
- save,
12
- set_audio_backend as _set_audio_backend,
13
- )
8
+ from . import compliance, datasets, functional, models, pipelines, transforms, utils # noqa: F401
14
9
  from ._torchcodec import load_with_torchcodec, save_with_torchcodec
15
10
 
16
- AudioMetaData = dropping_class_io_support(_AudioMetaData)
17
- get_audio_backend = dropping_io_support(_get_audio_backend)
18
- info = dropping_io_support(_info)
19
- list_audio_backends = dropping_io_support(_list_audio_backends)
20
- set_audio_backend = dropping_io_support(_set_audio_backend)
21
-
22
- from . import ( # noqa: F401
23
- compliance,
24
- datasets,
25
- functional,
26
- io,
27
- kaldi_io,
28
- models,
29
- pipelines,
30
- sox_effects,
31
- transforms,
32
- utils,
33
- )
34
-
35
- # For BC
36
- from . import backend # noqa # usort: skip
37
11
 
38
12
  try:
39
13
  from .version import __version__, git_version # noqa: F401
@@ -41,24 +15,190 @@ except ImportError:
41
15
  pass
42
16
 
43
17
 
18
+ def load(
19
+ uri: Union[BinaryIO, str, os.PathLike],
20
+ frame_offset: int = 0,
21
+ num_frames: int = -1,
22
+ normalize: bool = True,
23
+ channels_first: bool = True,
24
+ format: Optional[str] = None,
25
+ buffer_size: int = 4096,
26
+ backend: Optional[str] = None,
27
+ ) -> Tuple[torch.Tensor, int]:
28
+ """Load audio data from source using TorchCodec's AudioDecoder.
29
+
30
+ .. note::
31
+
32
+ As of TorchAudio 2.9, this function relies on TorchCodec's decoding capabilities under the hood. It is
33
+ provided for convenience, but we do recommend that you port your code to
34
+ natively use ``torchcodec``'s ``AudioDecoder`` class for better
35
+ performance:
36
+ https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.decoders.AudioDecoder.
37
+ Because of the reliance on Torchcodec, the parameters ``normalize``, ``buffer_size``, and
38
+ ``backend`` are ignored and accepted only for backwards compatibility.
39
+ To install torchcodec, follow the instructions at https://github.com/pytorch/torchcodec#installing-torchcodec.
40
+
41
+
42
+ Args:
43
+ uri (path-like object or file-like object):
44
+ Source of audio data. The following types are accepted:
45
+
46
+ * ``path-like``: File path or URL.
47
+ * ``file-like``: Object with ``read(size: int) -> bytes`` method.
48
+
49
+ frame_offset (int, optional):
50
+ Number of samples to skip before start reading data.
51
+ num_frames (int, optional):
52
+ Maximum number of samples to read. ``-1`` reads all the remaining samples,
53
+ starting from ``frame_offset``.
54
+ normalize (bool, optional):
55
+ TorchCodec always returns normalized float32 samples. This parameter
56
+ is ignored and a warning is issued if set to False.
57
+ Default: ``True``.
58
+ channels_first (bool, optional):
59
+ When True, the returned Tensor has dimension `[channel, time]`.
60
+ Otherwise, the returned Tensor's dimension is `[time, channel]`.
61
+ format (str or None, optional):
62
+ Format hint for the decoder. May not be supported by all TorchCodec
63
+ decoders. (Default: ``None``)
64
+ buffer_size (int, optional):
65
+ Not used by TorchCodec AudioDecoder. Provided for API compatibility.
66
+ backend (str or None, optional):
67
+ Not used by TorchCodec AudioDecoder. Provided for API compatibility.
68
+
69
+ Returns:
70
+ (torch.Tensor, int): Resulting Tensor and sample rate.
71
+ Always returns float32 tensors. If ``channels_first=True``, shape is
72
+ `[channel, time]`, otherwise `[time, channel]`.
73
+
74
+ Raises:
75
+ ImportError: If torchcodec is not available.
76
+ ValueError: If unsupported parameters are used.
77
+ RuntimeError: If TorchCodec fails to decode the audio.
78
+
79
+ Note:
80
+ - TorchCodec always returns normalized float32 samples, so the ``normalize``
81
+ parameter has no effect.
82
+ - The ``buffer_size`` and ``backend`` parameters are ignored.
83
+ - Not all audio formats supported by torchaudio backends may be supported
84
+ by TorchCodec.
85
+ """
86
+ return load_with_torchcodec(
87
+ uri,
88
+ frame_offset=frame_offset,
89
+ num_frames=num_frames,
90
+ normalize=normalize,
91
+ channels_first=channels_first,
92
+ format=format,
93
+ buffer_size=buffer_size,
94
+ backend=backend,
95
+ )
96
+
97
+
98
+ def save(
99
+ uri: Union[str, os.PathLike],
100
+ src: torch.Tensor,
101
+ sample_rate: int,
102
+ channels_first: bool = True,
103
+ format: Optional[str] = None,
104
+ encoding: Optional[str] = None,
105
+ bits_per_sample: Optional[int] = None,
106
+ buffer_size: int = 4096,
107
+ backend: Optional[str] = None,
108
+ compression: Optional[Union[float, int]] = None,
109
+ ) -> None:
110
+ """Save audio data to file using TorchCodec's AudioEncoder.
111
+
112
+ .. note::
113
+
114
+ As of TorchAudio 2.9, this function relies on TorchCodec's encoding capabilities under the hood.
115
+ It is provided for convenience, but we do recommend that you port your code to
116
+ natively use ``torchcodec``'s ``AudioEncoder`` class for better
117
+ performance:
118
+ https://docs.pytorch.org/torchcodec/stable/generated/torchcodec.encoders.AudioEncoder.
119
+ Because of the reliance on Torchcodec, the parameters ``format``, ``encoding``,
120
+ ``bits_per_sample``, ``buffer_size``, and ``backend``, are ignored and accepted only for
121
+ backwards compatibility.
122
+ To install torchcodec, follow the instructions at https://github.com/pytorch/torchcodec#installing-torchcodec.
123
+
124
+ Args:
125
+ uri (path-like object):
126
+ Path to save the audio file. The file extension determines the format.
127
+
128
+ src (torch.Tensor):
129
+ Audio data to save. Must be a 1D or 2D tensor with float32 values
130
+ in the range [-1, 1]. If 2D, shape should be [channel, time] when
131
+ channels_first=True, or [time, channel] when channels_first=False.
132
+
133
+ sample_rate (int):
134
+ Sample rate of the audio data.
135
+
136
+ channels_first (bool, optional):
137
+ Indicates whether the input tensor has channels as the first dimension.
138
+ If True, expects [channel, time]. If False, expects [time, channel].
139
+ Default: True.
140
+
141
+ format (str or None, optional):
142
+ Audio format hint. Not used by TorchCodec (format is determined by
143
+ file extension). A warning is issued if provided.
144
+ Default: None.
145
+
146
+ encoding (str or None, optional):
147
+ Audio encoding. Not fully supported by TorchCodec AudioEncoder.
148
+ A warning is issued if provided. Default: None.
149
+
150
+ bits_per_sample (int or None, optional):
151
+ Bits per sample. Not directly supported by TorchCodec AudioEncoder.
152
+ A warning is issued if provided. Default: None.
153
+
154
+ buffer_size (int, optional):
155
+ Not used by TorchCodec AudioEncoder. Provided for API compatibility.
156
+ A warning is issued if not default value. Default: 4096.
157
+
158
+ backend (str or None, optional):
159
+ Not used by TorchCodec AudioEncoder. Provided for API compatibility.
160
+ A warning is issued if provided. Default: None.
161
+
162
+ compression (float, int or None, optional):
163
+ Compression level or bit rate. Maps to bit_rate parameter in
164
+ TorchCodec AudioEncoder. Default: None.
165
+
166
+ Raises:
167
+ ImportError: If torchcodec is not available.
168
+ ValueError: If input parameters are invalid.
169
+ RuntimeError: If TorchCodec fails to encode the audio.
170
+
171
+ Note:
172
+ - TorchCodec AudioEncoder expects float32 samples in [-1, 1] range.
173
+ - Some parameters (format, encoding, bits_per_sample, buffer_size, backend)
174
+ are not used by TorchCodec but are provided for API compatibility.
175
+ - The output format is determined by the file extension in the uri.
176
+ - TorchCodec uses FFmpeg under the hood for encoding.
177
+ """
178
+ return save_with_torchcodec(
179
+ uri,
180
+ src,
181
+ sample_rate,
182
+ channels_first=channels_first,
183
+ format=format,
184
+ encoding=encoding,
185
+ bits_per_sample=bits_per_sample,
186
+ buffer_size=buffer_size,
187
+ backend=backend,
188
+ compression=compression,
189
+ )
190
+
191
+
44
192
  __all__ = [
45
- "AudioMetaData",
46
193
  "load",
47
194
  "load_with_torchcodec",
48
195
  "save_with_torchcodec",
49
- "info",
50
196
  "save",
51
- "io",
52
197
  "compliance",
53
198
  "datasets",
54
199
  "functional",
55
200
  "models",
56
201
  "pipelines",
57
- "kaldi_io",
58
202
  "utils",
59
- "sox_effects",
60
203
  "transforms",
61
- "list_audio_backends",
62
- "get_audio_backend",
63
- "set_audio_backend",
64
204
  ]
@@ -4,7 +4,7 @@ import sys
4
4
 
5
5
  from torchaudio._internal.module_utils import fail_with_message, is_module_available, no_op
6
6
 
7
- from .utils import _check_cuda_version, _init_dll_path, _init_sox, _LazyImporter, _load_lib
7
+ from .utils import _check_cuda_version, _init_dll_path, _load_lib
8
8
 
9
9
  _LG = logging.getLogger(__name__)
10
10
 
@@ -17,7 +17,6 @@ __all__ = [
17
17
  "_check_cuda_version",
18
18
  "_IS_TORCHAUDIO_EXT_AVAILABLE",
19
19
  "_IS_RIR_AVAILABLE",
20
- "lazy_import_sox_ext",
21
20
  ]
22
21
 
23
22
 
@@ -44,18 +43,6 @@ if _IS_TORCHAUDIO_EXT_AVAILABLE:
44
43
  _IS_ALIGN_AVAILABLE = torchaudio.lib._torchaudio.is_align_available()
45
44
 
46
45
 
47
- _SOX_EXT = None
48
-
49
-
50
- def lazy_import_sox_ext():
51
- """Load SoX integration based on availability in lazy manner"""
52
-
53
- global _SOX_EXT
54
- if _SOX_EXT is None:
55
- _SOX_EXT = _LazyImporter("_torchaudio_sox", _init_sox)
56
- return _SOX_EXT
57
-
58
-
59
46
  fail_if_no_rir = (
60
47
  no_op
61
48
  if _IS_RIR_AVAILABLE
@@ -4,14 +4,12 @@ The implementations here should be stateless.
4
4
  They should not depend on external state.
5
5
  Anything that depends on external state should happen in __init__.py
6
6
  """
7
- import importlib
8
7
  import logging
9
8
  import os
10
9
  import types
11
10
  from pathlib import Path
12
11
 
13
12
  import torch
14
- from torchaudio._internal.module_utils import eval_env
15
13
 
16
14
  _LG = logging.getLogger(__name__)
17
15
  _LIB_DIR = Path(__file__).parent.parent / "lib"
@@ -61,51 +59,6 @@ def _load_lib(lib: str) -> bool:
61
59
  return True
62
60
 
63
61
 
64
- def _import_sox_ext():
65
- if os.name == "nt":
66
- raise RuntimeError("sox extension is not supported on Windows")
67
- if not eval_env("TORCHAUDIO_USE_SOX", True):
68
- raise RuntimeError("sox extension is disabled. (TORCHAUDIO_USE_SOX=0)")
69
-
70
- ext = "torchaudio.lib._torchaudio_sox"
71
-
72
- if not importlib.util.find_spec(ext):
73
- raise RuntimeError(
74
- # fmt: off
75
- "TorchAudio is not built with sox extension. "
76
- "Please build TorchAudio with libsox support. (BUILD_SOX=1)"
77
- # fmt: on
78
- )
79
-
80
- _load_lib("libtorchaudio_sox")
81
- return importlib.import_module(ext)
82
-
83
-
84
- def _init_sox():
85
- ext = _import_sox_ext()
86
- ext.set_verbosity(0)
87
-
88
- import atexit
89
-
90
- torch.ops.torchaudio_sox.initialize_sox_effects()
91
- atexit.register(torch.ops.torchaudio_sox.shutdown_sox_effects)
92
-
93
- # Bundle functions registered with TORCH_LIBRARY into extension
94
- # so that they can also be accessed in the same (lazy) manner
95
- # from the extension.
96
- keys = [
97
- "get_info",
98
- "load_audio_file",
99
- "save_audio_file",
100
- "apply_effects_tensor",
101
- "apply_effects_file",
102
- ]
103
- for key in keys:
104
- setattr(ext, key, getattr(torch.ops.torchaudio_sox, key))
105
-
106
- return ext
107
-
108
-
109
62
  class _LazyImporter(types.ModuleType):
110
63
  """Lazily import module/extension."""
111
64
 
@@ -1,7 +1,7 @@
1
1
  import importlib.util
2
2
  import os
3
3
  import warnings
4
- from functools import wraps, partial
4
+ from functools import partial, wraps
5
5
  from typing import Optional
6
6
 
7
7
 
@@ -59,8 +59,10 @@ def requires_module(*modules: str):
59
59
 
60
60
  return decorator
61
61
 
62
+
62
63
  UNSUPPORTED = []
63
64
 
65
+
64
66
  def wrap_deprecated(func, name, direction: str, version: Optional[str] = None, remove: bool = False):
65
67
  @wraps(func)
66
68
  def wrapped(*args, **kwargs):
@@ -69,8 +71,10 @@ def wrap_deprecated(func, name, direction: str, version: Optional[str] = None, r
69
71
  message += f' It will be removed from {"a future" if version is None else "the " + str(version)} release. '
70
72
  warnings.warn(message, stacklevel=2)
71
73
  return func(*args, **kwargs)
74
+
72
75
  return wrapped
73
76
 
77
+
74
78
  def deprecated(direction: str, version: Optional[str] = None, remove: bool = False):
75
79
  """Decorator to add deprecation message
76
80
 
@@ -97,11 +101,11 @@ def deprecated(direction: str, version: Optional[str] = None, remove: bool = Fal
97
101
  {func.__doc__}
98
102
  """
99
103
 
100
- UNSUPPORTED.append(wrapped)
101
104
  return wrapped
102
105
 
103
106
  return decorator
104
107
 
108
+
105
109
  DEPRECATION_MSG = (
106
110
  "This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. "
107
111
  "Please see https://github.com/pytorch/audio/issues/3902 for more information."
@@ -109,12 +113,14 @@ DEPRECATION_MSG = (
109
113
 
110
114
  IO_DEPRECATION_MSG = (
111
115
  "This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. "
112
- "The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. "
116
+ "The decoding and encoding capabilities of PyTorch for both audio"
117
+ " and video are being consolidated into TorchCodec. "
113
118
  "Please see https://github.com/pytorch/audio/issues/3902 for more information."
114
119
  )
115
120
 
116
121
  dropping_support = deprecated(DEPRECATION_MSG, version="2.9", remove=True)
117
122
 
123
+
118
124
  def dropping_class_support(c, msg=DEPRECATION_MSG):
119
125
  c.__init__ = wrap_deprecated(c.__init__, f"{c.__module__}.{c.__name__}", msg, version="2.9", remove=True)
120
126
  c.__doc__ = f"""DEPRECATED
@@ -129,6 +135,7 @@ def dropping_class_support(c, msg=DEPRECATION_MSG):
129
135
  UNSUPPORTED.append(c)
130
136
  return c
131
137
 
138
+
132
139
  def dropping_const_support(c, msg=DEPRECATION_MSG, name=None):
133
140
  c.__doc__ = f"""[DEPRECATED]
134
141
 
@@ -140,10 +147,12 @@ def dropping_const_support(c, msg=DEPRECATION_MSG, name=None):
140
147
  """
141
148
  return c
142
149
 
150
+
143
151
  dropping_class_io_support = partial(dropping_class_support, msg=IO_DEPRECATION_MSG)
144
152
 
145
153
  dropping_io_support = deprecated(IO_DEPRECATION_MSG, version="2.9", remove=True)
146
154
 
155
+
147
156
  def fail_with_message(message):
148
157
  """Generate decorator to give users message about missing TorchAudio extension."""
149
158