torchaudio 2.8.0__cp313-cp313-win_amd64.whl → 2.9.0__cp313-cp313-win_amd64.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 (92) 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.pyd +0 -0
  13. torchaudio/lib/libtorchaudio.pyd +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/prototype/__init__.py +0 -0
  50. torchaudio/prototype/datasets/__init__.py +0 -4
  51. torchaudio/prototype/datasets/musan.py +0 -68
  52. torchaudio/prototype/functional/__init__.py +0 -26
  53. torchaudio/prototype/functional/_dsp.py +0 -441
  54. torchaudio/prototype/functional/_rir.py +0 -382
  55. torchaudio/prototype/functional/functional.py +0 -193
  56. torchaudio/prototype/models/__init__.py +0 -39
  57. torchaudio/prototype/models/_conformer_wav2vec2.py +0 -801
  58. torchaudio/prototype/models/_emformer_hubert.py +0 -337
  59. torchaudio/prototype/models/conv_emformer.py +0 -529
  60. torchaudio/prototype/models/hifi_gan.py +0 -342
  61. torchaudio/prototype/models/rnnt.py +0 -717
  62. torchaudio/prototype/models/rnnt_decoder.py +0 -402
  63. torchaudio/prototype/pipelines/__init__.py +0 -21
  64. torchaudio/prototype/pipelines/_vggish/__init__.py +0 -7
  65. torchaudio/prototype/pipelines/_vggish/_vggish_impl.py +0 -236
  66. torchaudio/prototype/pipelines/_vggish/_vggish_pipeline.py +0 -83
  67. torchaudio/prototype/pipelines/hifigan_pipeline.py +0 -233
  68. torchaudio/prototype/pipelines/rnnt_pipeline.py +0 -58
  69. torchaudio/prototype/transforms/__init__.py +0 -9
  70. torchaudio/prototype/transforms/_transforms.py +0 -461
  71. torchaudio/sox_effects/__init__.py +0 -10
  72. torchaudio/sox_effects/sox_effects.py +0 -275
  73. torchaudio/utils/ffmpeg_utils.py +0 -11
  74. torchaudio/utils/sox_utils.py +0 -118
  75. torchaudio-2.8.0.dist-info/RECORD +0 -145
  76. torio/__init__.py +0 -8
  77. torio/_extension/__init__.py +0 -13
  78. torio/_extension/utils.py +0 -147
  79. torio/io/__init__.py +0 -9
  80. torio/io/_streaming_media_decoder.py +0 -977
  81. torio/io/_streaming_media_encoder.py +0 -502
  82. torio/lib/__init__.py +0 -0
  83. torio/lib/_torio_ffmpeg4.pyd +0 -0
  84. torio/lib/_torio_ffmpeg5.pyd +0 -0
  85. torio/lib/_torio_ffmpeg6.pyd +0 -0
  86. torio/lib/libtorio_ffmpeg4.pyd +0 -0
  87. torio/lib/libtorio_ffmpeg5.pyd +0 -0
  88. torio/lib/libtorio_ffmpeg6.pyd +0 -0
  89. torio/utils/__init__.py +0 -4
  90. torio/utils/ffmpeg_utils.py +0 -275
  91. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/WHEEL +0 -0
  92. {torchaudio-2.8.0.dist-info → torchaudio-2.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,342 +0,0 @@
1
- """
2
- MIT License
3
-
4
- Copyright (c) 2020 Jungil Kong
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
- """
24
-
25
- from typing import Tuple
26
-
27
- import torch
28
- import torch.nn as nn
29
- import torch.nn.functional as F
30
- from torch.nn import Conv1d, ConvTranspose1d
31
- from torchaudio._internal.module_utils import dropping_class_support, dropping_support
32
-
33
-
34
- @dropping_class_support
35
- class HiFiGANVocoder(torch.nn.Module):
36
- """Generator part of *HiFi GAN* :cite:`NEURIPS2020_c5d73680`.
37
- Source: https://github.com/jik876/hifi-gan/blob/4769534d45265d52a904b850da5a622601885777/models.py#L75
38
-
39
- Note:
40
- To build the model, please use one of the factory functions: :py:func:`hifigan_vocoder`,
41
- :py:func:`hifigan_vocoder_v1`, :py:func:`hifigan_vocoder_v2`, :py:func:`hifigan_vocoder_v3`.
42
-
43
- Args:
44
- in_channels (int): Number of channels in the input features.
45
- upsample_rates (tuple of ``int``): Factors by which each upsampling layer increases the time dimension.
46
- upsample_initial_channel (int): Number of channels in the input feature tensor.
47
- upsample_kernel_sizes (tuple of ``int``): Kernel size for each upsampling layer.
48
- resblock_kernel_sizes (tuple of ``int``): Kernel size for each residual block.
49
- resblock_dilation_sizes (tuple of tuples of ``int``): Dilation sizes for each 1D convolutional layer in each
50
- residual block. For resblock type 1 inner tuples should have length 3, because there are 3
51
- convolutions in each layer. For resblock type 2 they should have length 2.
52
- resblock_type (int, 1 or 2): Determines whether ``ResBlock1`` or ``ResBlock2`` will be used.
53
- lrelu_slope (float): Slope of leaky ReLUs in activations.
54
- """
55
-
56
- def __init__(
57
- self,
58
- in_channels: int,
59
- upsample_rates: Tuple[int, ...],
60
- upsample_initial_channel: int,
61
- upsample_kernel_sizes: Tuple[int, ...],
62
- resblock_kernel_sizes: Tuple[int, ...],
63
- resblock_dilation_sizes: Tuple[Tuple[int, ...], ...],
64
- resblock_type: int,
65
- lrelu_slope: float,
66
- ):
67
- super(HiFiGANVocoder, self).__init__()
68
- self.num_kernels = len(resblock_kernel_sizes)
69
- self.num_upsamples = len(upsample_rates)
70
- self.conv_pre = Conv1d(in_channels, upsample_initial_channel, 7, 1, padding=3)
71
- resblock = ResBlock1 if resblock_type == 1 else ResBlock2
72
-
73
- self.ups = nn.ModuleList()
74
- for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
75
- self.ups.append(
76
- ConvTranspose1d(
77
- upsample_initial_channel // (2**i),
78
- upsample_initial_channel // (2 ** (i + 1)),
79
- k,
80
- u,
81
- padding=(k - u) // 2,
82
- )
83
- )
84
-
85
- self.resblocks = nn.ModuleList()
86
- for i in range(len(self.ups)):
87
- ch = upsample_initial_channel // (2 ** (i + 1))
88
- for (k, d) in zip(resblock_kernel_sizes, resblock_dilation_sizes):
89
- self.resblocks.append(resblock(ch, k, d, lrelu_slope))
90
-
91
- self.conv_post = Conv1d(ch, 1, 7, 1, padding=3)
92
- self.lrelu_slope = lrelu_slope
93
-
94
- def forward(self, x: torch.Tensor) -> torch.Tensor:
95
- """
96
- Args:
97
- x (Tensor): Feature input tensor of shape `(batch_size, num_channels, time_length)`.
98
-
99
- Returns:
100
- Tensor of shape `(batch_size, 1, time_length * upsample_rate)`, where `upsample_rate` is the product
101
- of upsample rates for all layers.
102
- """
103
- x = self.conv_pre(x)
104
- for i, upsampling_layer in enumerate(self.ups):
105
- x = F.leaky_relu(x, self.lrelu_slope)
106
- x = upsampling_layer(x)
107
- xs = torch.zeros_like(x)
108
- for j in range(self.num_kernels):
109
- res_block: ResBlockInterface = self.resblocks[i * self.num_kernels + j]
110
- xs += res_block.forward(x)
111
- x = xs / self.num_kernels
112
-
113
- x = F.leaky_relu(x)
114
- x = self.conv_post(x)
115
- x = torch.tanh(x)
116
-
117
- return x
118
-
119
-
120
- @torch.jit.interface
121
- class ResBlockInterface(torch.nn.Module):
122
- """Interface for ResBlock - necessary to make type annotations in ``HiFiGANVocoder.forward`` compatible
123
- with TorchScript
124
- """
125
-
126
- def forward(self, x: torch.Tensor) -> torch.Tensor:
127
- pass
128
-
129
-
130
- class ResBlock1(torch.nn.Module):
131
- """Residual block of type 1 for HiFiGAN Vocoder :cite:`NEURIPS2020_c5d73680`.
132
- Args:
133
- channels (int): Number of channels in the input features.
134
- kernel_size (int, optional): Kernel size for 1D convolutions. (Default: ``3``)
135
- dilation (tuple of 3 ``int``, optional): Dilations for each 1D convolution. (Default: ``(1, 3, 5)``)
136
- lrelu_slope (float): Slope of leaky ReLUs in activations.
137
- """
138
-
139
- def __init__(
140
- self, channels: int, kernel_size: int = 3, dilation: Tuple[int, int, int] = (1, 3, 5), lrelu_slope: float = 0.1
141
- ):
142
- super(ResBlock1, self).__init__()
143
- self.convs1 = nn.ModuleList(
144
- [
145
- Conv1d(
146
- channels,
147
- channels,
148
- kernel_size,
149
- 1,
150
- dilation=dilation[0],
151
- padding=get_padding(kernel_size, dilation[0]),
152
- ),
153
- Conv1d(
154
- channels,
155
- channels,
156
- kernel_size,
157
- 1,
158
- dilation=dilation[1],
159
- padding=get_padding(kernel_size, dilation[1]),
160
- ),
161
- Conv1d(
162
- channels,
163
- channels,
164
- kernel_size,
165
- 1,
166
- dilation=dilation[2],
167
- padding=get_padding(kernel_size, dilation[2]),
168
- ),
169
- ]
170
- )
171
-
172
- self.convs2 = nn.ModuleList(
173
- [
174
- Conv1d(channels, channels, kernel_size, 1, dilation=1, padding=get_padding(kernel_size, 1)),
175
- Conv1d(channels, channels, kernel_size, 1, dilation=1, padding=get_padding(kernel_size, 1)),
176
- Conv1d(channels, channels, kernel_size, 1, dilation=1, padding=get_padding(kernel_size, 1)),
177
- ]
178
- )
179
- self.lrelu_slope = lrelu_slope
180
-
181
- def forward(self, x: torch.Tensor) -> torch.Tensor:
182
- """
183
- Args:
184
- x (Tensor): input of shape ``(batch_size, channels, time_length)``.
185
- Returns:
186
- Tensor of the same shape as input.
187
- """
188
- for conv1, conv2 in zip(self.convs1, self.convs2):
189
- xt = F.leaky_relu(x, self.lrelu_slope)
190
- xt = conv1(xt)
191
- xt = F.leaky_relu(xt, self.lrelu_slope)
192
- xt = conv2(xt)
193
- x = xt + x
194
- return x
195
-
196
-
197
- class ResBlock2(torch.nn.Module):
198
- """Residual block of type 2 for HiFiGAN Vocoder :cite:`NEURIPS2020_c5d73680`.
199
- Args:
200
- channels (int): Number of channels in the input features.
201
- kernel_size (int, optional): Kernel size for 1D convolutions. (Default: ``3``)
202
- dilation (tuple of 2 ``int``, optional): Dilations for each 1D convolution. (Default: ``(1, 3)``)
203
- lrelu_slope (float): Slope of leaky ReLUs in activations.
204
- """
205
-
206
- def __init__(
207
- self, channels: int, kernel_size: int = 3, dilation: Tuple[int, int] = (1, 3), lrelu_slope: float = 0.1
208
- ):
209
- super(ResBlock2, self).__init__()
210
- self.convs = nn.ModuleList(
211
- [
212
- Conv1d(
213
- channels,
214
- channels,
215
- kernel_size,
216
- 1,
217
- dilation=dilation[0],
218
- padding=get_padding(kernel_size, dilation[0]),
219
- ),
220
- Conv1d(
221
- channels,
222
- channels,
223
- kernel_size,
224
- 1,
225
- dilation=dilation[1],
226
- padding=get_padding(kernel_size, dilation[1]),
227
- ),
228
- ]
229
- )
230
- self.lrelu_slope = lrelu_slope
231
-
232
- def forward(self, x: torch.Tensor):
233
- """
234
- Args:
235
- x (Tensor): input of shape ``(batch_size, channels, time_length)``.
236
- Returns:
237
- Tensor of the same shape as input.
238
- """
239
- for c in self.convs:
240
- xt = F.leaky_relu(x, self.lrelu_slope)
241
- xt = c(xt)
242
- x = xt + x
243
- return x
244
-
245
-
246
- def get_padding(kernel_size, dilation=1):
247
- """Find padding for which 1D convolution preserves the input shape."""
248
- return int((kernel_size * dilation - dilation) / 2)
249
-
250
-
251
- @dropping_support
252
- def hifigan_vocoder(
253
- in_channels: int,
254
- upsample_rates: Tuple[int, ...],
255
- upsample_initial_channel: int,
256
- upsample_kernel_sizes: Tuple[int, ...],
257
- resblock_kernel_sizes: Tuple[int, ...],
258
- resblock_dilation_sizes: Tuple[Tuple[int, ...], ...],
259
- resblock_type: int,
260
- lrelu_slope: float,
261
- ) -> HiFiGANVocoder:
262
- r"""Builds HiFi GAN Vocoder :cite:`NEURIPS2020_c5d73680`.
263
-
264
- Args:
265
- in_channels (int): See :py:class:`HiFiGANVocoder`.
266
- upsample_rates (tuple of ``int``): See :py:class:`HiFiGANVocoder`.
267
- upsample_initial_channel (int): See :py:class:`HiFiGANVocoder`.
268
- upsample_kernel_sizes (tuple of ``int``): See :py:class:`HiFiGANVocoder`.
269
- resblock_kernel_sizes (tuple of ``int``): See :py:class:`HiFiGANVocoder`.
270
- resblock_dilation_sizes (tuple of tuples of ``int``): See :py:class:`HiFiGANVocoder`.
271
- resblock_type (int, 1 or 2): See :py:class:`HiFiGANVocoder`.
272
- Returns:
273
- HiFiGANVocoder: generated model.
274
- """
275
-
276
- return HiFiGANVocoder(
277
- upsample_rates=upsample_rates,
278
- resblock_kernel_sizes=resblock_kernel_sizes,
279
- resblock_dilation_sizes=resblock_dilation_sizes,
280
- resblock_type=resblock_type,
281
- upsample_initial_channel=upsample_initial_channel,
282
- upsample_kernel_sizes=upsample_kernel_sizes,
283
- in_channels=in_channels,
284
- lrelu_slope=lrelu_slope,
285
- )
286
-
287
-
288
- @dropping_support
289
- def hifigan_vocoder_v1() -> HiFiGANVocoder:
290
- r"""Builds HiFiGAN Vocoder with V1 architecture :cite:`NEURIPS2020_c5d73680`.
291
-
292
- Returns:
293
- HiFiGANVocoder: generated model.
294
- """
295
- return hifigan_vocoder(
296
- upsample_rates=(8, 8, 2, 2),
297
- upsample_kernel_sizes=(16, 16, 4, 4),
298
- upsample_initial_channel=512,
299
- resblock_kernel_sizes=(3, 7, 11),
300
- resblock_dilation_sizes=((1, 3, 5), (1, 3, 5), (1, 3, 5)),
301
- resblock_type=1,
302
- in_channels=80,
303
- lrelu_slope=0.1,
304
- )
305
-
306
-
307
- @dropping_support
308
- def hifigan_vocoder_v2() -> HiFiGANVocoder:
309
- r"""Builds HiFiGAN Vocoder with V2 architecture :cite:`NEURIPS2020_c5d73680`.
310
-
311
- Returns:
312
- HiFiGANVocoder: generated model.
313
- """
314
- return hifigan_vocoder(
315
- upsample_rates=(8, 8, 2, 2),
316
- upsample_kernel_sizes=(16, 16, 4, 4),
317
- upsample_initial_channel=128,
318
- resblock_kernel_sizes=(3, 7, 11),
319
- resblock_dilation_sizes=((1, 3, 5), (1, 3, 5), (1, 3, 5)),
320
- resblock_type=1,
321
- in_channels=80,
322
- lrelu_slope=0.1,
323
- )
324
-
325
-
326
- @dropping_support
327
- def hifigan_vocoder_v3() -> HiFiGANVocoder:
328
- r"""Builds HiFiGAN Vocoder with V3 architecture :cite:`NEURIPS2020_c5d73680`.
329
-
330
- Returns:
331
- HiFiGANVocoder: generated model.
332
- """
333
- return hifigan_vocoder(
334
- upsample_rates=(8, 8, 4),
335
- upsample_kernel_sizes=(16, 16, 8),
336
- upsample_initial_channel=256,
337
- resblock_kernel_sizes=(3, 5, 7),
338
- resblock_dilation_sizes=((1, 2), (2, 6), (3, 12)),
339
- resblock_type=2,
340
- in_channels=80,
341
- lrelu_slope=0.1,
342
- )