Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/INSTALLER +1 -0
- lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/METADATA +35 -0
- lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/RECORD +107 -0
- lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/REQUESTED +0 -0
- lib/python3.12/site-packages/sniffio/__init__.py +17 -0
- lib/python3.12/site-packages/sniffio/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sniffio/__pycache__/_impl.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sniffio/__pycache__/_version.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sniffio/_impl.py +95 -0
- lib/python3.12/site-packages/sniffio/_tests/__init__.py +0 -0
- lib/python3.12/site-packages/sniffio/_tests/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sniffio/_tests/__pycache__/test_sniffio.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/sniffio/_tests/test_sniffio.py +84 -0
- lib/python3.12/site-packages/sniffio/_version.py +3 -0
- lib/python3.12/site-packages/sniffio/py.typed +0 -0
- lib/python3.12/site-packages/torchaudio/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/__pycache__/kaldi_io.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/__pycache__/version.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/_no_backend.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/_sox_io_backend.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/common.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/no_backend.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/soundfile_backend.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/__pycache__/sox_io_backend.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/backend/no_backend.py +14 -0
- lib/python3.12/site-packages/torchaudio/io/__init__.py +13 -0
- lib/python3.12/site-packages/torchaudio/io/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/io/__pycache__/_effector.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/io/__pycache__/_playback.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/io/_effector.py +347 -0
- lib/python3.12/site-packages/torchaudio/io/_playback.py +72 -0
- lib/python3.12/site-packages/torchaudio/pipelines/__init__.py +102 -0
- lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/_source_separation_pipeline.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/_squim_pipeline.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/rnnt_pipeline.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_source_separation_pipeline.py +109 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_squim_pipeline.py +156 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/__init__.py +16 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/impl.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/interface.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/utils.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/impl.py +385 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/interface.py +255 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_tts/utils.py +228 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__init__.py +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__pycache__/__init__.cpython-312.pyc +0 -0
- lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__pycache__/aligner.cpython-312.pyc +0 -0
lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/METADATA
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: nvidia-cuda-runtime-cu12
|
| 3 |
+
Version: 12.4.127
|
| 4 |
+
Summary: CUDA Runtime native Libraries
|
| 5 |
+
Home-page: https://developer.nvidia.com/cuda-zone
|
| 6 |
+
Author: Nvidia CUDA Installer Team
|
| 7 |
+
Author-email: cuda_installer@nvidia.com
|
| 8 |
+
License: NVIDIA Proprietary Software
|
| 9 |
+
Keywords: cuda,nvidia,runtime,machine learning,deep learning
|
| 10 |
+
Classifier: Development Status :: 4 - Beta
|
| 11 |
+
Classifier: Intended Audience :: Developers
|
| 12 |
+
Classifier: Intended Audience :: Education
|
| 13 |
+
Classifier: Intended Audience :: Science/Research
|
| 14 |
+
Classifier: License :: Other/Proprietary License
|
| 15 |
+
Classifier: Natural Language :: English
|
| 16 |
+
Classifier: Programming Language :: Python :: 3
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.5
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 24 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 25 |
+
Classifier: Topic :: Scientific/Engineering
|
| 26 |
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
| 27 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
| 28 |
+
Classifier: Topic :: Software Development
|
| 29 |
+
Classifier: Topic :: Software Development :: Libraries
|
| 30 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 31 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 32 |
+
Requires-Python: >=3
|
| 33 |
+
License-File: License.txt
|
| 34 |
+
|
| 35 |
+
CUDA Runtime native Libraries
|
lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/RECORD
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
nvidia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 2 |
+
nvidia/__pycache__/__init__.cpython-312.pyc,,
|
| 3 |
+
nvidia/cuda_runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 4 |
+
nvidia/cuda_runtime/__pycache__/__init__.cpython-312.pyc,,
|
| 5 |
+
nvidia/cuda_runtime/include/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
nvidia/cuda_runtime/include/__pycache__/__init__.cpython-312.pyc,,
|
| 7 |
+
nvidia/cuda_runtime/include/builtin_types.h,sha256=JxT9Vf2q2snxTBOL9ACzNmYzTWACO2VOVUu1KdFt7_g,3150
|
| 8 |
+
nvidia/cuda_runtime/include/channel_descriptor.h,sha256=no_vNky02LeMLI0CF8GDVGHaPm_uRUGcVUMYdt_Xn4U,21482
|
| 9 |
+
nvidia/cuda_runtime/include/common_functions.h,sha256=22LTZRVcPZzEH6MJda7nNMCvMgIjSTe0OKR7sEQj6kc,3410
|
| 10 |
+
nvidia/cuda_runtime/include/cooperative_groups.h,sha256=JUBW-C1x_7WWuNOaoorTKQab0qzrykkG8oAw1mEHZ2s,60332
|
| 11 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/async.h,sha256=xsEHCZP3nuEY3l2p8SU2d1226XiXumUvDP_Gyh8PdVY,19122
|
| 12 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/coalesced_reduce.h,sha256=pBQgFY7i64V87XNATg1UEIQHVNYOItQtHjS5B4yn8pc,4257
|
| 13 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/coalesced_scan.h,sha256=DfZv5d5W0XJv-tZVhgrIdjLjs6aCx_u0oy1lDIpjo1Q,7314
|
| 14 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/driver_abi.h,sha256=v-ZUb4UgGKJk6NR2WCWHD3x_42y-togI1urFn70Gi-g,3964
|
| 15 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/functional.h,sha256=2BV8i8Bidz0kgxuYkJCAbwFxOIZRyzHgG-c_rVKhRzc,8905
|
| 16 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/helpers.h,sha256=K9jvxnXc5-6Fum1KG4EQKJJrVZ4BhHOSAJbZR4uDL0c,26476
|
| 17 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/info.h,sha256=Ij_cqIrcXCcwlaQqCL7AHzMD4H89y0tJeQXCbjTGsFo,12578
|
| 18 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/invoke.h,sha256=Osq3K-tZuXHVCMQJ708PjPo-BwMhjhjApO4b0TYLFJg,8616
|
| 19 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/memory.h,sha256=WU28eUcYLA1z131VYGulR4eVCSN9xK9KSxbV656YPs0,5484
|
| 20 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/partitioning.h,sha256=4UXuvUmZvGANy0hd4erdBNllpgnn4K4qFWWlfzAsHO8,7125
|
| 21 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/reduce.h,sha256=UfMezM5pqRIotJjmuFgOmiMvbu49sYgjraHutmVVr0w,22111
|
| 22 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/scan.h,sha256=-Ttwb2AfEEY_tsmqJjR2dojkPpoRx387SoqxgvfdBtQ,17166
|
| 23 |
+
nvidia/cuda_runtime/include/cooperative_groups/details/sync.h,sha256=zoiBicvB7rlXa_r_VSNuvHVwrLIM7EjF_KdmhvPj1LM,10638
|
| 24 |
+
nvidia/cuda_runtime/include/cooperative_groups/memcpy_async.h,sha256=erOIHuObdfxRhBWfrXE3wsZF4B2GUuqwzQrsPwKPpbg,2960
|
| 25 |
+
nvidia/cuda_runtime/include/cooperative_groups/reduce.h,sha256=B0hgDkqM-6ueqTTgb3b34A0RH4vGz8mBf5e2jT1dJ1o,2949
|
| 26 |
+
nvidia/cuda_runtime/include/cooperative_groups/scan.h,sha256=2EU6T5cWNwftm2B7FicV31PojoI61yo5fHXGRYkGk40,2940
|
| 27 |
+
nvidia/cuda_runtime/include/cuComplex.h,sha256=WpcgpaiPhU_o9sTPMcNTEZuyXDIc8x3sz4dUWSztL2g,12186
|
| 28 |
+
nvidia/cuda_runtime/include/cuda.h,sha256=29OuNnfs8Hb2sqCXHUKy3VudXxzN8050d0oW_C33ysE,1048458
|
| 29 |
+
nvidia/cuda_runtime/include/cudaEGL.h,sha256=_CwaQ4cEP1vfNyBSSd5qFxznPCYOovF6Cpj-QWSIBq4,39544
|
| 30 |
+
nvidia/cuda_runtime/include/cudaEGLTypedefs.h,sha256=xF_FAN1Kar9oyHJ3cCU7jztTpxX8WylpiuYyYpGGHek,5645
|
| 31 |
+
nvidia/cuda_runtime/include/cudaGL.h,sha256=gMT1HPGa-siuji0gAsKYr4X45Lc29HKglC_ttNSGyUM,22501
|
| 32 |
+
nvidia/cuda_runtime/include/cudaGLTypedefs.h,sha256=dClpQI-LuXgF9rPSBsj7OkIg8g_fXDjT0hLZS8TGpOg,6576
|
| 33 |
+
nvidia/cuda_runtime/include/cudaProfilerTypedefs.h,sha256=F2aWLIKv_AhNbxNOaZVcRsxIh0kuscnV8UMWWxkBAlY,3297
|
| 34 |
+
nvidia/cuda_runtime/include/cudaTypedefs.h,sha256=0hWYyV-KM7R5Qjagz9UP1ldhAZDHGIcJmYtYvB_nwNc,110387
|
| 35 |
+
nvidia/cuda_runtime/include/cudaVDPAU.h,sha256=Np7Nc2Wjaz--hkpbhW6f9aapr-NbcPDAgkot0sJerco,12694
|
| 36 |
+
nvidia/cuda_runtime/include/cudaVDPAUTypedefs.h,sha256=wz8nyOUdwM9mH9JO3QZW-A9dyxt-IufSX7nggSXpCNs,4144
|
| 37 |
+
nvidia/cuda_runtime/include/cuda_awbarrier.h,sha256=3ZH-ZlXODhSiwSY9rqSni_EQwi25QMHP6Tm-zOdxBwE,9340
|
| 38 |
+
nvidia/cuda_runtime/include/cuda_awbarrier_helpers.h,sha256=OCskCts5bCKl_RKBe9M74zKSIsVpePn44S_aJp1tFXE,12489
|
| 39 |
+
nvidia/cuda_runtime/include/cuda_awbarrier_primitives.h,sha256=n5__E1jYYDhlgH-f3u8MQjtz57UZ7v5VshhMye1eicM,4699
|
| 40 |
+
nvidia/cuda_runtime/include/cuda_bf16.h,sha256=CUmV313-EoESxCNDiAC1azacAWxzzVWj7vE7bZNoebI,188194
|
| 41 |
+
nvidia/cuda_runtime/include/cuda_bf16.hpp,sha256=Z2hjeJHZMwa-VQCgd5BNsJjo9rRfK2wqJH942HTVrQE,134181
|
| 42 |
+
nvidia/cuda_runtime/include/cuda_device_runtime_api.h,sha256=bIhfusirXe5-osOTPAILDh6pY8MW1hefyZvTD_IzgqM,46249
|
| 43 |
+
nvidia/cuda_runtime/include/cuda_egl_interop.h,sha256=PNWYns30MIytJQHSOh7UbZYlaTX5e0bavzK14tde_C8,37109
|
| 44 |
+
nvidia/cuda_runtime/include/cuda_fp16.h,sha256=4yaQaQw0__T0TOOr37gtz-l1zxOc8nH-qhJ6RSk30OU,178258
|
| 45 |
+
nvidia/cuda_runtime/include/cuda_fp16.hpp,sha256=wgSLe8EsVPul3XEpm4kD0k9jmmxlyHNiiZPpGpDU8dQ,119751
|
| 46 |
+
nvidia/cuda_runtime/include/cuda_fp8.h,sha256=Q3OP5o_3rSYbKtVIlcXVr_CncU3SPM-09j605e2Zegw,13833
|
| 47 |
+
nvidia/cuda_runtime/include/cuda_fp8.hpp,sha256=b-PcyZgei5MmIp6op0QQ40BgNupO_ei648hG_dUS-FQ,64246
|
| 48 |
+
nvidia/cuda_runtime/include/cuda_gl_interop.h,sha256=VQEswFeOBF6JN6Q0pdlkvc5WT7bD1FnTfKewvANulCc,19150
|
| 49 |
+
nvidia/cuda_runtime/include/cuda_occupancy.h,sha256=Kr9HyOe-hlRjBAzbINwUYkNgbbIgIjuvKs09UZhMYQo,67179
|
| 50 |
+
nvidia/cuda_runtime/include/cuda_pipeline.h,sha256=0enXG49wN4JajlQi3ahbp2ei_ufTY_Mznic7zfWmKHM,8130
|
| 51 |
+
nvidia/cuda_runtime/include/cuda_pipeline_helpers.h,sha256=bo1L7e6vCuM-K3Il8K1z4wJUja5DyXQKdo_hSWUME-E,13852
|
| 52 |
+
nvidia/cuda_runtime/include/cuda_pipeline_primitives.h,sha256=FnJJtuV6rHr6LgL56XDwilcSbFr6W1Hj6mf1AJaMI20,8675
|
| 53 |
+
nvidia/cuda_runtime/include/cuda_runtime.h,sha256=a-OXWPsmKSPst7mRCCxHNZV7m-uRLCAY8oGRi-dJzPA,90683
|
| 54 |
+
nvidia/cuda_runtime/include/cuda_runtime_api.h,sha256=7Ys9yv_2trFEVybtbh-UJKnDKG8fHWvUjSX4cgZGCck,608580
|
| 55 |
+
nvidia/cuda_runtime/include/cuda_surface_types.h,sha256=Mw5Lo4b8Q-f9mogOvATGyHhu9d2t2K6XOxuqtZrSh3A,3688
|
| 56 |
+
nvidia/cuda_runtime/include/cuda_texture_types.h,sha256=ITbX-JNnP7Rm-JSgNVdJ9pq6k8FVor8RbnruDsKq6sk,3688
|
| 57 |
+
nvidia/cuda_runtime/include/cuda_vdpau_interop.h,sha256=bXQanWc2IFXZAKWNGl2xAz9nLvFmQpWyGrsDvfeS9FA,7727
|
| 58 |
+
nvidia/cuda_runtime/include/cudart_platform.h,sha256=YN6sKhB0b9w5tGX1IYL7ulJVPrWAiX9A44qLv4EtW5Q,2717
|
| 59 |
+
nvidia/cuda_runtime/include/device_atomic_functions.h,sha256=OR2jNSfSKzaFri74zh4Vtz5M0z9UDBU3rKeC1rYaVQs,9500
|
| 60 |
+
nvidia/cuda_runtime/include/device_atomic_functions.hpp,sha256=0e7MOiNNUnnloXpB_r9WT5YOws5cxgzQQAzRCYvgaFA,10486
|
| 61 |
+
nvidia/cuda_runtime/include/device_double_functions.h,sha256=KUxId5Z1fx8SWfLRTxPD7RB-zN7zslzb4n7JaJLfL3I,3452
|
| 62 |
+
nvidia/cuda_runtime/include/device_functions.h,sha256=bWSrhTYE9NQlss7xMSMEVusvto9j2fgUDXWVH2W_cOA,3410
|
| 63 |
+
nvidia/cuda_runtime/include/device_launch_parameters.h,sha256=H1_CC-vvAaS26ys4XsTFkMgTxUTciAjdjswjizkisvQ,3846
|
| 64 |
+
nvidia/cuda_runtime/include/device_types.h,sha256=2LFxoZBJPoA5V0H1EbKTEaXDi3GDJPtzOPdRHDaucIQ,3588
|
| 65 |
+
nvidia/cuda_runtime/include/driver_functions.h,sha256=cN3IjRAz2Mj2Pj35SyxJIkZNDDusnJqaqzBdMzpQKbA,4625
|
| 66 |
+
nvidia/cuda_runtime/include/driver_types.h,sha256=4eBQ10Nzgfs2BlxGaGHVMWLvnJfKrEnMml9zfFi0DyA,177782
|
| 67 |
+
nvidia/cuda_runtime/include/host_config.h,sha256=BscH_GazAZbbotddVzL5RmafbQ-QjRx8f-I1O01IBW8,3380
|
| 68 |
+
nvidia/cuda_runtime/include/host_defines.h,sha256=bBQwQF5C1N1c2qpLV56g1c-weu9Ysgz-gIf2Kn3uz_A,3386
|
| 69 |
+
nvidia/cuda_runtime/include/library_types.h,sha256=p6746aCd_A_1VlgKRhLJChzeZ4tN7e4HBH2Hm7hDjbU,4836
|
| 70 |
+
nvidia/cuda_runtime/include/math_constants.h,sha256=cV6hAyQe8X7f7MBtaKjjIJq3BycOUDp6I5cizJX5HLw,7608
|
| 71 |
+
nvidia/cuda_runtime/include/math_functions.h,sha256=5XcC6j-fJKttvhwc4hZNoLHNw808a2ZYIOtZ7ry7yd0,3398
|
| 72 |
+
nvidia/cuda_runtime/include/mma.h,sha256=IY_VenxuEncwGq92MhrWUb-Xswh0ekAXLy9Rbxhxa2Y,2932
|
| 73 |
+
nvidia/cuda_runtime/include/sm_20_atomic_functions.h,sha256=x4ycINVq__l9B4SQPD-I48jQbKxxdBmgp8Vf2GO0Qfg,4478
|
| 74 |
+
nvidia/cuda_runtime/include/sm_20_atomic_functions.hpp,sha256=1l5NLM8DhDbqYZ_E51LoqElQJXObkbwo57d3r-4uEbE,4107
|
| 75 |
+
nvidia/cuda_runtime/include/sm_20_intrinsics.h,sha256=a4jDSp_DUW0d09g5wgEm_I7bGTAe73HKRinkhBKQBis,51048
|
| 76 |
+
nvidia/cuda_runtime/include/sm_20_intrinsics.hpp,sha256=BhEBuXSKBsNGJDBJDtYL0cGRI3wX_w_OIgA5D-YxIWk,7694
|
| 77 |
+
nvidia/cuda_runtime/include/sm_30_intrinsics.h,sha256=b6W8Vxp9vD9OCJI6lZuGyZYXEdQ3Ei8PTAloHNkwCcQ,16978
|
| 78 |
+
nvidia/cuda_runtime/include/sm_30_intrinsics.hpp,sha256=yX0ebd265tJ-BDhvluP2BhadPuWXpRZPI2eeQFFt5ys,24567
|
| 79 |
+
nvidia/cuda_runtime/include/sm_32_atomic_functions.h,sha256=HGnZgQHACE2AAb6zabGUURc53IsVZelc2BSJqvs9OgY,5703
|
| 80 |
+
nvidia/cuda_runtime/include/sm_32_atomic_functions.hpp,sha256=CQTTvOEYp-s5hqAgLvAon11vLYDrDp8cTHdel-XRzBQ,6592
|
| 81 |
+
nvidia/cuda_runtime/include/sm_32_intrinsics.h,sha256=Xdkogdsjy1vh8u3eGu0i5xTmHxBGAjj6_vVGR-spdOE,33539
|
| 82 |
+
nvidia/cuda_runtime/include/sm_32_intrinsics.hpp,sha256=Gl8aSLDLcit4W3pKQS19GsDG8RYcwD65HwYB_CeZe8M,70616
|
| 83 |
+
nvidia/cuda_runtime/include/sm_35_atomic_functions.h,sha256=a3XoEsKRCEOf0Q_5Y__rMfmC4pScv4VkUggVgVJVn44,2909
|
| 84 |
+
nvidia/cuda_runtime/include/sm_35_intrinsics.h,sha256=0mS5-LCgvZiTvL7-MG_4YwI-zWGvM-s4xyRuMkunMC8,2664
|
| 85 |
+
nvidia/cuda_runtime/include/sm_60_atomic_functions.h,sha256=_anfNaJsvQpDEorYeUKIkbizYkwrinBcG_ZCiECtLqI,13178
|
| 86 |
+
nvidia/cuda_runtime/include/sm_60_atomic_functions.hpp,sha256=cgIKddDn2B3QzYlzeBILAP1IRys74QCCxsH0QqaVGls,22903
|
| 87 |
+
nvidia/cuda_runtime/include/sm_61_intrinsics.h,sha256=h_MBL1UUDxQX_qOddSImzqyFjcrhhm_63G97pGDyreU,10902
|
| 88 |
+
nvidia/cuda_runtime/include/sm_61_intrinsics.hpp,sha256=N-nQvcBsPMT2Umy5zR69c9K1q366W-Jqe7NpoLTqTmg,6787
|
| 89 |
+
nvidia/cuda_runtime/include/surface_functions.h,sha256=b1O82SAvEgWWxA9uZTWQcGimzZUoem2QbAET3wh3fZc,6782
|
| 90 |
+
nvidia/cuda_runtime/include/surface_indirect_functions.h,sha256=vy9QuFVV-ezZP-x2RT9RLp2qIUgdngACOCmalSfVFPA,10877
|
| 91 |
+
nvidia/cuda_runtime/include/surface_types.h,sha256=XkFXD1nHbeSMgajR-UJE9uQ7TByzJnjdnUL4-yGiufk,4530
|
| 92 |
+
nvidia/cuda_runtime/include/texture_fetch_functions.h,sha256=KLCmUxf5aY5_UalX8tSFB6e4TrjA8hyUPxLOkMFltAo,12468
|
| 93 |
+
nvidia/cuda_runtime/include/texture_indirect_functions.h,sha256=lH_y3Ni-hq4RZ0_PMFbBM0th5-OmTn3TtqtpkHHhA8w,21163
|
| 94 |
+
nvidia/cuda_runtime/include/texture_types.h,sha256=73ntVyg8r8fzKy5VIk6yuvC45GDeWepaLIqIk-M3Ri8,6360
|
| 95 |
+
nvidia/cuda_runtime/include/vector_functions.h,sha256=WypGkL-IDbGOlay7g_G0p3HO7OLGRE0Do__JtiFoWxY,8003
|
| 96 |
+
nvidia/cuda_runtime/include/vector_functions.hpp,sha256=afXhNSd3LFTZo96EPtesTLfvxd4nTmLVzgkj967rTRg,10060
|
| 97 |
+
nvidia/cuda_runtime/include/vector_types.h,sha256=6CJ4yt3KD7zQVfm1NhrgqNYYEDEIZWwaivlFx12nhNg,13396
|
| 98 |
+
nvidia/cuda_runtime/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 99 |
+
nvidia/cuda_runtime/lib/__pycache__/__init__.cpython-312.pyc,,
|
| 100 |
+
nvidia/cuda_runtime/lib/libcudart.so.12,sha256=h3QiT1sRpzsV0HSj_M5zJzIsXEz9_ZJNaoJnee7JaP4,707904
|
| 101 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 102 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/License.txt,sha256=rW9YU_ugyg0VnQ9Y1JrkmDDC-Mk_epJki5zpCttMbM0,59262
|
| 103 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/METADATA,sha256=AcAo5k7tWjg-wgkViCrnv6J1v-QkwuViwNkUy8Pfk_0,1507
|
| 104 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/RECORD,,
|
| 105 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 106 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/WHEEL,sha256=XDTs3wIbcE-BcRO08VJlZpA6z9OaC1mOKPCGGGwuM2g,109
|
| 107 |
+
nvidia_cuda_runtime_cu12-12.4.127.dist-info/top_level.txt,sha256=fTkAtiFuL16nUrB9ytDDtpytz2t0B4NvYTnRzwAhO14,7
|
lib/python3.12/site-packages/nvidia_cuda_runtime_cu12-12.4.127.dist-info/REQUESTED
ADDED
|
File without changes
|
lib/python3.12/site-packages/sniffio/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Top-level package for sniffio."""
|
| 2 |
+
|
| 3 |
+
__all__ = [
|
| 4 |
+
"current_async_library",
|
| 5 |
+
"AsyncLibraryNotFoundError",
|
| 6 |
+
"current_async_library_cvar",
|
| 7 |
+
"thread_local",
|
| 8 |
+
]
|
| 9 |
+
|
| 10 |
+
from ._version import __version__
|
| 11 |
+
|
| 12 |
+
from ._impl import (
|
| 13 |
+
current_async_library,
|
| 14 |
+
AsyncLibraryNotFoundError,
|
| 15 |
+
current_async_library_cvar,
|
| 16 |
+
thread_local,
|
| 17 |
+
)
|
lib/python3.12/site-packages/sniffio/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (462 Bytes). View file
|
|
|
lib/python3.12/site-packages/sniffio/__pycache__/_impl.cpython-312.pyc
ADDED
|
Binary file (3.17 kB). View file
|
|
|
lib/python3.12/site-packages/sniffio/__pycache__/_version.cpython-312.pyc
ADDED
|
Binary file (214 Bytes). View file
|
|
|
lib/python3.12/site-packages/sniffio/_impl.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from contextvars import ContextVar
|
| 2 |
+
from typing import Optional
|
| 3 |
+
import sys
|
| 4 |
+
import threading
|
| 5 |
+
|
| 6 |
+
current_async_library_cvar = ContextVar(
|
| 7 |
+
"current_async_library_cvar", default=None
|
| 8 |
+
) # type: ContextVar[Optional[str]]
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class _ThreadLocal(threading.local):
|
| 12 |
+
# Since threading.local provides no explicit mechanism is for setting
|
| 13 |
+
# a default for a value, a custom class with a class attribute is used
|
| 14 |
+
# instead.
|
| 15 |
+
name = None # type: Optional[str]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
thread_local = _ThreadLocal()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class AsyncLibraryNotFoundError(RuntimeError):
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def current_async_library() -> str:
|
| 26 |
+
"""Detect which async library is currently running.
|
| 27 |
+
|
| 28 |
+
The following libraries are currently supported:
|
| 29 |
+
|
| 30 |
+
================ =========== ============================
|
| 31 |
+
Library Requires Magic string
|
| 32 |
+
================ =========== ============================
|
| 33 |
+
**Trio** Trio v0.6+ ``"trio"``
|
| 34 |
+
**Curio** - ``"curio"``
|
| 35 |
+
**asyncio** ``"asyncio"``
|
| 36 |
+
**Trio-asyncio** v0.8.2+ ``"trio"`` or ``"asyncio"``,
|
| 37 |
+
depending on current mode
|
| 38 |
+
================ =========== ============================
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
A string like ``"trio"``.
|
| 42 |
+
|
| 43 |
+
Raises:
|
| 44 |
+
AsyncLibraryNotFoundError: if called from synchronous context,
|
| 45 |
+
or if the current async library was not recognized.
|
| 46 |
+
|
| 47 |
+
Examples:
|
| 48 |
+
|
| 49 |
+
.. code-block:: python3
|
| 50 |
+
|
| 51 |
+
from sniffio import current_async_library
|
| 52 |
+
|
| 53 |
+
async def generic_sleep(seconds):
|
| 54 |
+
library = current_async_library()
|
| 55 |
+
if library == "trio":
|
| 56 |
+
import trio
|
| 57 |
+
await trio.sleep(seconds)
|
| 58 |
+
elif library == "asyncio":
|
| 59 |
+
import asyncio
|
| 60 |
+
await asyncio.sleep(seconds)
|
| 61 |
+
# ... and so on ...
|
| 62 |
+
else:
|
| 63 |
+
raise RuntimeError(f"Unsupported library {library!r}")
|
| 64 |
+
|
| 65 |
+
"""
|
| 66 |
+
value = thread_local.name
|
| 67 |
+
if value is not None:
|
| 68 |
+
return value
|
| 69 |
+
|
| 70 |
+
value = current_async_library_cvar.get()
|
| 71 |
+
if value is not None:
|
| 72 |
+
return value
|
| 73 |
+
|
| 74 |
+
# Need to sniff for asyncio
|
| 75 |
+
if "asyncio" in sys.modules:
|
| 76 |
+
import asyncio
|
| 77 |
+
try:
|
| 78 |
+
current_task = asyncio.current_task # type: ignore[attr-defined]
|
| 79 |
+
except AttributeError:
|
| 80 |
+
current_task = asyncio.Task.current_task # type: ignore[attr-defined]
|
| 81 |
+
try:
|
| 82 |
+
if current_task() is not None:
|
| 83 |
+
return "asyncio"
|
| 84 |
+
except RuntimeError:
|
| 85 |
+
pass
|
| 86 |
+
|
| 87 |
+
# Sniff for curio (for now)
|
| 88 |
+
if 'curio' in sys.modules:
|
| 89 |
+
from curio.meta import curio_running
|
| 90 |
+
if curio_running():
|
| 91 |
+
return 'curio'
|
| 92 |
+
|
| 93 |
+
raise AsyncLibraryNotFoundError(
|
| 94 |
+
"unknown async library, or not in async context"
|
| 95 |
+
)
|
lib/python3.12/site-packages/sniffio/_tests/__init__.py
ADDED
|
File without changes
|
lib/python3.12/site-packages/sniffio/_tests/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (193 Bytes). View file
|
|
|
lib/python3.12/site-packages/sniffio/_tests/__pycache__/test_sniffio.cpython-312.pyc
ADDED
|
Binary file (3.85 kB). View file
|
|
|
lib/python3.12/site-packages/sniffio/_tests/test_sniffio.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from .. import (
|
| 7 |
+
current_async_library, AsyncLibraryNotFoundError,
|
| 8 |
+
current_async_library_cvar, thread_local
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def test_basics_cvar():
|
| 13 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 14 |
+
current_async_library()
|
| 15 |
+
|
| 16 |
+
token = current_async_library_cvar.set("generic-lib")
|
| 17 |
+
try:
|
| 18 |
+
assert current_async_library() == "generic-lib"
|
| 19 |
+
finally:
|
| 20 |
+
current_async_library_cvar.reset(token)
|
| 21 |
+
|
| 22 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 23 |
+
current_async_library()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def test_basics_tlocal():
|
| 27 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 28 |
+
current_async_library()
|
| 29 |
+
|
| 30 |
+
old_name, thread_local.name = thread_local.name, "generic-lib"
|
| 31 |
+
try:
|
| 32 |
+
assert current_async_library() == "generic-lib"
|
| 33 |
+
finally:
|
| 34 |
+
thread_local.name = old_name
|
| 35 |
+
|
| 36 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 37 |
+
current_async_library()
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def test_asyncio():
|
| 41 |
+
import asyncio
|
| 42 |
+
|
| 43 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 44 |
+
current_async_library()
|
| 45 |
+
|
| 46 |
+
ran = []
|
| 47 |
+
|
| 48 |
+
async def this_is_asyncio():
|
| 49 |
+
assert current_async_library() == "asyncio"
|
| 50 |
+
# Call it a second time to exercise the caching logic
|
| 51 |
+
assert current_async_library() == "asyncio"
|
| 52 |
+
ran.append(True)
|
| 53 |
+
|
| 54 |
+
asyncio.run(this_is_asyncio())
|
| 55 |
+
assert ran == [True]
|
| 56 |
+
|
| 57 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 58 |
+
current_async_library()
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
@pytest.mark.skipif(
|
| 62 |
+
sys.version_info >= (3, 12),
|
| 63 |
+
reason=
|
| 64 |
+
"curio broken on 3.12 (https://github.com/python-trio/sniffio/pull/42)",
|
| 65 |
+
)
|
| 66 |
+
def test_curio():
|
| 67 |
+
import curio
|
| 68 |
+
|
| 69 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 70 |
+
current_async_library()
|
| 71 |
+
|
| 72 |
+
ran = []
|
| 73 |
+
|
| 74 |
+
async def this_is_curio():
|
| 75 |
+
assert current_async_library() == "curio"
|
| 76 |
+
# Call it a second time to exercise the caching logic
|
| 77 |
+
assert current_async_library() == "curio"
|
| 78 |
+
ran.append(True)
|
| 79 |
+
|
| 80 |
+
curio.run(this_is_curio)
|
| 81 |
+
assert ran == [True]
|
| 82 |
+
|
| 83 |
+
with pytest.raises(AsyncLibraryNotFoundError):
|
| 84 |
+
current_async_library()
|
lib/python3.12/site-packages/sniffio/_version.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is imported from __init__.py and exec'd from setup.py
|
| 2 |
+
|
| 3 |
+
__version__ = "1.3.1"
|
lib/python3.12/site-packages/sniffio/py.typed
ADDED
|
File without changes
|
lib/python3.12/site-packages/torchaudio/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (920 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/__pycache__/kaldi_io.cpython-312.pyc
ADDED
|
Binary file (5.55 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/__pycache__/version.cpython-312.pyc
ADDED
|
Binary file (284 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (329 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/_no_backend.cpython-312.pyc
ADDED
|
Binary file (1.39 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/_sox_io_backend.cpython-312.pyc
ADDED
|
Binary file (12.4 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/common.cpython-312.pyc
ADDED
|
Binary file (772 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/no_backend.cpython-312.pyc
ADDED
|
Binary file (802 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/soundfile_backend.cpython-312.pyc
ADDED
|
Binary file (830 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/__pycache__/sox_io_backend.cpython-312.pyc
ADDED
|
Binary file (810 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/backend/no_backend.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def __getattr__(name: str):
|
| 2 |
+
import warnings
|
| 3 |
+
|
| 4 |
+
warnings.warn(
|
| 5 |
+
"Torchaudio's I/O functions now support par-call bakcend dispatch. "
|
| 6 |
+
"Importing backend implementation directly is no longer guaranteed to work. "
|
| 7 |
+
"Please use `backend` keyword with load/save/info function, instead of "
|
| 8 |
+
"calling the udnerlying implementation directly.",
|
| 9 |
+
stacklevel=2,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
from . import _no_backend
|
| 13 |
+
|
| 14 |
+
return getattr(_no_backend, name)
|
lib/python3.12/site-packages/torchaudio/io/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torio.io import CodecConfig, StreamingMediaDecoder as StreamReader, StreamingMediaEncoder as StreamWriter
|
| 2 |
+
|
| 3 |
+
from ._effector import AudioEffector
|
| 4 |
+
from ._playback import play_audio
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
__all__ = [
|
| 8 |
+
"AudioEffector",
|
| 9 |
+
"StreamReader",
|
| 10 |
+
"StreamWriter",
|
| 11 |
+
"CodecConfig",
|
| 12 |
+
"play_audio",
|
| 13 |
+
]
|
lib/python3.12/site-packages/torchaudio/io/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (483 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/io/__pycache__/_effector.cpython-312.pyc
ADDED
|
Binary file (14.7 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/io/__pycache__/_playback.cpython-312.pyc
ADDED
|
Binary file (3.43 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/io/_effector.py
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import io
|
| 2 |
+
from typing import Iterator, List, Optional
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
from torio.io._streaming_media_decoder import _get_afilter_desc, StreamingMediaDecoder as StreamReader
|
| 8 |
+
from torio.io._streaming_media_encoder import CodecConfig, StreamingMediaEncoder as StreamWriter
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class _StreamingIOBuffer:
|
| 12 |
+
"""Streaming Bytes IO buffer. Data are dropped when read."""
|
| 13 |
+
|
| 14 |
+
def __init__(self):
|
| 15 |
+
self._buffer: List(bytes) = []
|
| 16 |
+
|
| 17 |
+
def write(self, b: bytes):
|
| 18 |
+
if b:
|
| 19 |
+
self._buffer.append(b)
|
| 20 |
+
return len(b)
|
| 21 |
+
|
| 22 |
+
def pop(self, n):
|
| 23 |
+
"""Pop the oldest byte string. It does not necessary return the requested amount"""
|
| 24 |
+
if not self._buffer:
|
| 25 |
+
return b""
|
| 26 |
+
if len(self._buffer[0]) <= n:
|
| 27 |
+
return self._buffer.pop(0)
|
| 28 |
+
ret = self._buffer[0][:n]
|
| 29 |
+
self._buffer[0] = self._buffer[0][n:]
|
| 30 |
+
return ret
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _get_sample_fmt(dtype: torch.dtype):
|
| 34 |
+
types = {
|
| 35 |
+
torch.uint8: "u8",
|
| 36 |
+
torch.int16: "s16",
|
| 37 |
+
torch.int32: "s32",
|
| 38 |
+
torch.float32: "flt",
|
| 39 |
+
torch.float64: "dbl",
|
| 40 |
+
}
|
| 41 |
+
if dtype not in types:
|
| 42 |
+
raise ValueError(f"Unsupported dtype is provided {dtype}. Supported dtypes are: {types.keys()}")
|
| 43 |
+
return types[dtype]
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class _AudioStreamingEncoder:
|
| 47 |
+
"""Given a waveform, encode on-demand and return bytes"""
|
| 48 |
+
|
| 49 |
+
def __init__(
|
| 50 |
+
self,
|
| 51 |
+
src: Tensor,
|
| 52 |
+
sample_rate: int,
|
| 53 |
+
effect: str,
|
| 54 |
+
muxer: str,
|
| 55 |
+
encoder: Optional[str],
|
| 56 |
+
codec_config: Optional[CodecConfig],
|
| 57 |
+
frames_per_chunk: int,
|
| 58 |
+
):
|
| 59 |
+
self.src = src
|
| 60 |
+
self.buffer = _StreamingIOBuffer()
|
| 61 |
+
self.writer = StreamWriter(self.buffer, format=muxer)
|
| 62 |
+
self.writer.add_audio_stream(
|
| 63 |
+
num_channels=src.size(1),
|
| 64 |
+
sample_rate=sample_rate,
|
| 65 |
+
format=_get_sample_fmt(src.dtype),
|
| 66 |
+
encoder=encoder,
|
| 67 |
+
filter_desc=effect,
|
| 68 |
+
codec_config=codec_config,
|
| 69 |
+
)
|
| 70 |
+
self.writer.open()
|
| 71 |
+
self.fpc = frames_per_chunk
|
| 72 |
+
|
| 73 |
+
# index on the input tensor (along time-axis)
|
| 74 |
+
# we use -1 to indicate that we finished iterating the tensor and
|
| 75 |
+
# the writer is closed.
|
| 76 |
+
self.i_iter = 0
|
| 77 |
+
|
| 78 |
+
def read(self, n):
|
| 79 |
+
while not self.buffer._buffer and self.i_iter >= 0:
|
| 80 |
+
self.writer.write_audio_chunk(0, self.src[self.i_iter : self.i_iter + self.fpc])
|
| 81 |
+
self.i_iter += self.fpc
|
| 82 |
+
if self.i_iter >= self.src.size(0):
|
| 83 |
+
self.writer.flush()
|
| 84 |
+
self.writer.close()
|
| 85 |
+
self.i_iter = -1
|
| 86 |
+
return self.buffer.pop(n)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _encode(
|
| 90 |
+
src: Tensor,
|
| 91 |
+
sample_rate: int,
|
| 92 |
+
effect: str,
|
| 93 |
+
muxer: str,
|
| 94 |
+
encoder: Optional[str],
|
| 95 |
+
codec_config: Optional[CodecConfig],
|
| 96 |
+
):
|
| 97 |
+
buffer = io.BytesIO()
|
| 98 |
+
writer = StreamWriter(buffer, format=muxer)
|
| 99 |
+
writer.add_audio_stream(
|
| 100 |
+
num_channels=src.size(1),
|
| 101 |
+
sample_rate=sample_rate,
|
| 102 |
+
format=_get_sample_fmt(src.dtype),
|
| 103 |
+
encoder=encoder,
|
| 104 |
+
filter_desc=effect,
|
| 105 |
+
codec_config=codec_config,
|
| 106 |
+
)
|
| 107 |
+
with writer.open():
|
| 108 |
+
writer.write_audio_chunk(0, src)
|
| 109 |
+
buffer.seek(0)
|
| 110 |
+
return buffer
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def _get_muxer(dtype: torch.dtype):
|
| 114 |
+
# TODO: check if this works in Windows.
|
| 115 |
+
types = {
|
| 116 |
+
torch.uint8: "u8",
|
| 117 |
+
torch.int16: "s16le",
|
| 118 |
+
torch.int32: "s32le",
|
| 119 |
+
torch.float32: "f32le",
|
| 120 |
+
torch.float64: "f64le",
|
| 121 |
+
}
|
| 122 |
+
if dtype not in types:
|
| 123 |
+
raise ValueError(f"Unsupported dtype is provided {dtype}. Supported dtypes are: {types.keys()}")
|
| 124 |
+
return types[dtype]
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
class AudioEffector:
|
| 128 |
+
"""Apply various filters and/or codecs to waveforms.
|
| 129 |
+
|
| 130 |
+
.. versionadded:: 2.1
|
| 131 |
+
|
| 132 |
+
Args:
|
| 133 |
+
effect (str or None, optional): Filter expressions or ``None`` to apply no filter.
|
| 134 |
+
See https://ffmpeg.org/ffmpeg-filters.html#Audio-Filters for the
|
| 135 |
+
details of filter syntax.
|
| 136 |
+
|
| 137 |
+
format (str or None, optional): When provided, encode the audio into the
|
| 138 |
+
corresponding format. Default: ``None``.
|
| 139 |
+
|
| 140 |
+
encoder (str or None, optional): When provided, override the encoder used
|
| 141 |
+
by the ``format``. Default: ``None``.
|
| 142 |
+
|
| 143 |
+
codec_config (CodecConfig or None, optional): When provided, configure the encoding codec.
|
| 144 |
+
Should be provided in conjunction with ``format`` option.
|
| 145 |
+
|
| 146 |
+
pad_end (bool, optional): When enabled, and if the waveform becomes shorter after applying
|
| 147 |
+
effects/codec, then pad the end with silence.
|
| 148 |
+
|
| 149 |
+
Example - Basic usage
|
| 150 |
+
To use ``AudioEffector``, first instantiate it with a set of
|
| 151 |
+
``effect`` and ``format``.
|
| 152 |
+
|
| 153 |
+
>>> # instantiate the effector
|
| 154 |
+
>>> effector = AudioEffector(effect=..., format=...)
|
| 155 |
+
|
| 156 |
+
Then, use :py:meth:`~AudioEffector.apply` or :py:meth:`~AudioEffector.stream`
|
| 157 |
+
method to apply them.
|
| 158 |
+
|
| 159 |
+
>>> # Apply the effect to the whole waveform
|
| 160 |
+
>>> applied = effector.apply(waveform, sample_rate)
|
| 161 |
+
|
| 162 |
+
>>> # Apply the effect chunk-by-chunk
|
| 163 |
+
>>> for chunk in effector.stream(waveform, sample_rate):
|
| 164 |
+
>>> ...
|
| 165 |
+
|
| 166 |
+
Example - Applying effects
|
| 167 |
+
Please refer to
|
| 168 |
+
https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-description
|
| 169 |
+
for the overview of filter description, and
|
| 170 |
+
https://ffmpeg.org/ffmpeg-filters.html#toc-Audio-Filters
|
| 171 |
+
for the list of available filters.
|
| 172 |
+
|
| 173 |
+
Tempo - https://ffmpeg.org/ffmpeg-filters.html#atempo
|
| 174 |
+
|
| 175 |
+
>>> AudioEffector(effect="atempo=1.5")
|
| 176 |
+
|
| 177 |
+
Echo - https://ffmpeg.org/ffmpeg-filters.html#aecho
|
| 178 |
+
|
| 179 |
+
>>> AudioEffector(effect="aecho=0.8:0.88:60:0.4")
|
| 180 |
+
|
| 181 |
+
Flanger - https://ffmpeg.org/ffmpeg-filters.html#flanger
|
| 182 |
+
|
| 183 |
+
>>> AudioEffector(effect="aflanger")
|
| 184 |
+
|
| 185 |
+
Vibrato - https://ffmpeg.org/ffmpeg-filters.html#vibrato
|
| 186 |
+
|
| 187 |
+
>>> AudioEffector(effect="vibrato")
|
| 188 |
+
|
| 189 |
+
Tremolo - https://ffmpeg.org/ffmpeg-filters.html#tremolo
|
| 190 |
+
|
| 191 |
+
>>> AudioEffector(effect="vibrato")
|
| 192 |
+
|
| 193 |
+
You can also apply multiple effects at once.
|
| 194 |
+
|
| 195 |
+
>>> AudioEffector(effect="")
|
| 196 |
+
|
| 197 |
+
Example - Applying codec
|
| 198 |
+
One can apply codec using ``format`` argument. ``format`` can be
|
| 199 |
+
audio format or container format. If the container format supports
|
| 200 |
+
multiple encoders, you can specify it with ``encoder`` argument.
|
| 201 |
+
|
| 202 |
+
Wav format
|
| 203 |
+
(no compression is applied but samples are converted to
|
| 204 |
+
16-bit signed integer)
|
| 205 |
+
|
| 206 |
+
>>> AudioEffector(format="wav")
|
| 207 |
+
|
| 208 |
+
Ogg format with default encoder
|
| 209 |
+
|
| 210 |
+
>>> AudioEffector(format="ogg")
|
| 211 |
+
|
| 212 |
+
Ogg format with vorbis
|
| 213 |
+
|
| 214 |
+
>>> AudioEffector(format="ogg", encoder="vorbis")
|
| 215 |
+
|
| 216 |
+
Ogg format with opus
|
| 217 |
+
|
| 218 |
+
>>> AudioEffector(format="ogg", encoder="opus")
|
| 219 |
+
|
| 220 |
+
Webm format with opus
|
| 221 |
+
|
| 222 |
+
>>> AudioEffector(format="webm", encoder="opus")
|
| 223 |
+
|
| 224 |
+
Example - Applying codec with configuration
|
| 225 |
+
Reference: https://trac.ffmpeg.org/wiki/Encode/MP3
|
| 226 |
+
|
| 227 |
+
MP3 with default config
|
| 228 |
+
|
| 229 |
+
>>> AudioEffector(format="mp3")
|
| 230 |
+
|
| 231 |
+
MP3 with variable bitrate
|
| 232 |
+
|
| 233 |
+
>>> AudioEffector(format="mp3", codec_config=CodecConfig(qscale=5))
|
| 234 |
+
|
| 235 |
+
MP3 with constant bitrate
|
| 236 |
+
|
| 237 |
+
>>> AudioEffector(format="mp3", codec_config=CodecConfig(bit_rate=32_000))
|
| 238 |
+
"""
|
| 239 |
+
|
| 240 |
+
def __init__(
|
| 241 |
+
self,
|
| 242 |
+
effect: Optional[str] = None,
|
| 243 |
+
format: Optional[str] = None,
|
| 244 |
+
*,
|
| 245 |
+
encoder: Optional[str] = None,
|
| 246 |
+
codec_config: Optional[CodecConfig] = None,
|
| 247 |
+
pad_end: bool = True,
|
| 248 |
+
):
|
| 249 |
+
if format is None:
|
| 250 |
+
if encoder is not None or codec_config is not None:
|
| 251 |
+
raise ValueError("`encoder` and/or `condec_config` opions are provided without `format` option.")
|
| 252 |
+
self.effect = effect
|
| 253 |
+
self.format = format
|
| 254 |
+
self.encoder = encoder
|
| 255 |
+
self.codec_config = codec_config
|
| 256 |
+
self.pad_end = pad_end
|
| 257 |
+
|
| 258 |
+
def _get_reader(self, waveform, sample_rate, output_sample_rate, frames_per_chunk=None):
|
| 259 |
+
num_frames, num_channels = waveform.shape
|
| 260 |
+
|
| 261 |
+
if self.format is not None:
|
| 262 |
+
muxer = self.format
|
| 263 |
+
encoder = self.encoder
|
| 264 |
+
option = {}
|
| 265 |
+
# Some formats are headerless, so need to provide these infomation.
|
| 266 |
+
if self.format == "mulaw":
|
| 267 |
+
option = {"sample_rate": f"{sample_rate}", "channels": f"{num_channels}"}
|
| 268 |
+
|
| 269 |
+
else: # PCM
|
| 270 |
+
muxer = _get_muxer(waveform.dtype)
|
| 271 |
+
encoder = None
|
| 272 |
+
option = {"sample_rate": f"{sample_rate}", "channels": f"{num_channels}"}
|
| 273 |
+
|
| 274 |
+
if frames_per_chunk is None:
|
| 275 |
+
src = _encode(waveform, sample_rate, self.effect, muxer, encoder, self.codec_config)
|
| 276 |
+
else:
|
| 277 |
+
src = _AudioStreamingEncoder(
|
| 278 |
+
waveform, sample_rate, self.effect, muxer, encoder, self.codec_config, frames_per_chunk
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
output_sr = sample_rate if output_sample_rate is None else output_sample_rate
|
| 282 |
+
filter_desc = _get_afilter_desc(output_sr, _get_sample_fmt(waveform.dtype), num_channels)
|
| 283 |
+
if self.pad_end:
|
| 284 |
+
filter_desc = f"{filter_desc},apad=whole_len={num_frames}"
|
| 285 |
+
|
| 286 |
+
reader = StreamReader(src, format=muxer, option=option)
|
| 287 |
+
reader.add_audio_stream(frames_per_chunk or -1, -1, filter_desc=filter_desc)
|
| 288 |
+
return reader
|
| 289 |
+
|
| 290 |
+
def apply(self, waveform: Tensor, sample_rate: int, output_sample_rate: Optional[int] = None) -> Tensor:
|
| 291 |
+
"""Apply the effect and/or codecs to the whole tensor.
|
| 292 |
+
|
| 293 |
+
Args:
|
| 294 |
+
waveform (Tensor): The input waveform. Shape: ``(time, channel)``
|
| 295 |
+
sample_rate (int): Sample rate of the input waveform.
|
| 296 |
+
output_sample_rate (int or None, optional): Output sample rate.
|
| 297 |
+
If provided, override the output sample rate.
|
| 298 |
+
Otherwise, the resulting tensor is resampled to have
|
| 299 |
+
the same sample rate as the input.
|
| 300 |
+
Default: ``None``.
|
| 301 |
+
|
| 302 |
+
Returns:
|
| 303 |
+
Tensor:
|
| 304 |
+
Resulting Tensor. Shape: ``(time, channel)``. The number of frames
|
| 305 |
+
could be different from that of the input.
|
| 306 |
+
"""
|
| 307 |
+
if waveform.ndim != 2:
|
| 308 |
+
raise ValueError(f"Expected the input waveform to be 2D. Found: {waveform.ndim}")
|
| 309 |
+
|
| 310 |
+
if waveform.numel() == 0:
|
| 311 |
+
return waveform
|
| 312 |
+
|
| 313 |
+
reader = self._get_reader(waveform, sample_rate, output_sample_rate)
|
| 314 |
+
reader.process_all_packets()
|
| 315 |
+
(applied,) = reader.pop_chunks()
|
| 316 |
+
return Tensor(applied)
|
| 317 |
+
|
| 318 |
+
def stream(
|
| 319 |
+
self, waveform: Tensor, sample_rate: int, frames_per_chunk: int, output_sample_rate: Optional[int] = None
|
| 320 |
+
) -> Iterator[Tensor]:
|
| 321 |
+
"""Apply the effect and/or codecs to the given tensor chunk by chunk.
|
| 322 |
+
|
| 323 |
+
Args:
|
| 324 |
+
waveform (Tensor): The input waveform. Shape: ``(time, channel)``
|
| 325 |
+
sample_rate (int): Sample rate of the waveform.
|
| 326 |
+
frames_per_chunk (int): The number of frames to return at a time.
|
| 327 |
+
output_sample_rate (int or None, optional): Output sample rate.
|
| 328 |
+
If provided, override the output sample rate.
|
| 329 |
+
Otherwise, the resulting tensor is resampled to have
|
| 330 |
+
the same sample rate as the input.
|
| 331 |
+
Default: ``None``.
|
| 332 |
+
|
| 333 |
+
Returns:
|
| 334 |
+
Iterator[Tensor]:
|
| 335 |
+
Series of processed chunks. Shape: ``(time, channel)``, where the
|
| 336 |
+
the number of frames matches ``frames_per_chunk`` except the
|
| 337 |
+
last chunk, which could be shorter.
|
| 338 |
+
"""
|
| 339 |
+
if waveform.ndim != 2:
|
| 340 |
+
raise ValueError(f"Expected the input waveform to be 2D. Found: {waveform.ndim}")
|
| 341 |
+
|
| 342 |
+
if waveform.numel() == 0:
|
| 343 |
+
return waveform
|
| 344 |
+
|
| 345 |
+
reader = self._get_reader(waveform, sample_rate, output_sample_rate, frames_per_chunk)
|
| 346 |
+
for (applied,) in reader.stream():
|
| 347 |
+
yield Tensor(applied)
|
lib/python3.12/site-packages/torchaudio/io/_playback.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
from sys import platform
|
| 3 |
+
from typing import Optional
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
import torchaudio
|
| 7 |
+
|
| 8 |
+
dict_format = {
|
| 9 |
+
torch.uint8: "u8",
|
| 10 |
+
torch.int16: "s16",
|
| 11 |
+
torch.int32: "s32",
|
| 12 |
+
torch.int64: "s64",
|
| 13 |
+
torch.float32: "flt",
|
| 14 |
+
torch.float64: "dbl",
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def play_audio(
|
| 19 |
+
waveform: torch.Tensor,
|
| 20 |
+
sample_rate: Optional[float],
|
| 21 |
+
device: Optional[str] = None,
|
| 22 |
+
) -> None:
|
| 23 |
+
"""Plays audio through specified or available output device.
|
| 24 |
+
|
| 25 |
+
.. warning::
|
| 26 |
+
This function is currently only supported on MacOS, and requires
|
| 27 |
+
libavdevice (FFmpeg) with ``audiotoolbox`` output device.
|
| 28 |
+
|
| 29 |
+
.. note::
|
| 30 |
+
This function can play up to two audio channels.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
waveform: Tensor containing the audio to play.
|
| 34 |
+
Expected shape: `(time, num_channels)`.
|
| 35 |
+
sample_rate: Sample rate of the audio to play.
|
| 36 |
+
device: Output device to use. If None, the default device is used.
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
if platform == "darwin":
|
| 40 |
+
device = device or "audiotoolbox"
|
| 41 |
+
path = "-"
|
| 42 |
+
else:
|
| 43 |
+
raise ValueError(f"This function only supports MacOS, but current OS is {platform}")
|
| 44 |
+
|
| 45 |
+
available_devices = list(torchaudio.utils.ffmpeg_utils.get_output_devices().keys())
|
| 46 |
+
if device not in available_devices:
|
| 47 |
+
raise ValueError(f"Device {device} is not available. Available devices are: {available_devices}")
|
| 48 |
+
|
| 49 |
+
if waveform.dtype not in dict_format:
|
| 50 |
+
raise ValueError(f"Unsupported type {waveform.dtype}. The list of supported types is: {dict_format.keys()}")
|
| 51 |
+
format = dict_format[waveform.dtype]
|
| 52 |
+
|
| 53 |
+
if waveform.ndim != 2:
|
| 54 |
+
raise ValueError(f"Expected 2D tensor with shape `(time, num_channels)`, got {waveform.ndim}D tensor instead")
|
| 55 |
+
|
| 56 |
+
time, num_channels = waveform.size()
|
| 57 |
+
if num_channels > 2:
|
| 58 |
+
warnings.warn(
|
| 59 |
+
f"Expected up to 2 channels, got {num_channels} channels instead. "
|
| 60 |
+
"Only the first 2 channels will be played.",
|
| 61 |
+
stacklevel=2,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
# Write to speaker device
|
| 65 |
+
s = torchaudio.io.StreamWriter(dst=path, format=device)
|
| 66 |
+
s.add_audio_stream(sample_rate, num_channels, format=format)
|
| 67 |
+
|
| 68 |
+
# write audio to the device
|
| 69 |
+
block_size = 256
|
| 70 |
+
with s.open():
|
| 71 |
+
for i in range(0, time, block_size):
|
| 72 |
+
s.write_audio_chunk(0, waveform[i : i + block_size, :])
|
lib/python3.12/site-packages/torchaudio/pipelines/__init__.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._source_separation_pipeline import (
|
| 2 |
+
CONVTASNET_BASE_LIBRI2MIX,
|
| 3 |
+
HDEMUCS_HIGH_MUSDB,
|
| 4 |
+
HDEMUCS_HIGH_MUSDB_PLUS,
|
| 5 |
+
SourceSeparationBundle,
|
| 6 |
+
)
|
| 7 |
+
from ._squim_pipeline import SQUIM_OBJECTIVE, SQUIM_SUBJECTIVE, SquimObjectiveBundle, SquimSubjectiveBundle
|
| 8 |
+
from ._tts import (
|
| 9 |
+
TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH,
|
| 10 |
+
TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH,
|
| 11 |
+
TACOTRON2_WAVERNN_CHAR_LJSPEECH,
|
| 12 |
+
TACOTRON2_WAVERNN_PHONE_LJSPEECH,
|
| 13 |
+
Tacotron2TTSBundle,
|
| 14 |
+
)
|
| 15 |
+
from ._wav2vec2.impl import (
|
| 16 |
+
HUBERT_ASR_LARGE,
|
| 17 |
+
HUBERT_ASR_XLARGE,
|
| 18 |
+
HUBERT_BASE,
|
| 19 |
+
HUBERT_LARGE,
|
| 20 |
+
HUBERT_XLARGE,
|
| 21 |
+
MMS_FA,
|
| 22 |
+
VOXPOPULI_ASR_BASE_10K_DE,
|
| 23 |
+
VOXPOPULI_ASR_BASE_10K_EN,
|
| 24 |
+
VOXPOPULI_ASR_BASE_10K_ES,
|
| 25 |
+
VOXPOPULI_ASR_BASE_10K_FR,
|
| 26 |
+
VOXPOPULI_ASR_BASE_10K_IT,
|
| 27 |
+
WAV2VEC2_ASR_BASE_100H,
|
| 28 |
+
WAV2VEC2_ASR_BASE_10M,
|
| 29 |
+
WAV2VEC2_ASR_BASE_960H,
|
| 30 |
+
WAV2VEC2_ASR_LARGE_100H,
|
| 31 |
+
WAV2VEC2_ASR_LARGE_10M,
|
| 32 |
+
WAV2VEC2_ASR_LARGE_960H,
|
| 33 |
+
WAV2VEC2_ASR_LARGE_LV60K_100H,
|
| 34 |
+
WAV2VEC2_ASR_LARGE_LV60K_10M,
|
| 35 |
+
WAV2VEC2_ASR_LARGE_LV60K_960H,
|
| 36 |
+
WAV2VEC2_BASE,
|
| 37 |
+
WAV2VEC2_LARGE,
|
| 38 |
+
WAV2VEC2_LARGE_LV60K,
|
| 39 |
+
WAV2VEC2_XLSR53,
|
| 40 |
+
WAV2VEC2_XLSR_1B,
|
| 41 |
+
WAV2VEC2_XLSR_2B,
|
| 42 |
+
WAV2VEC2_XLSR_300M,
|
| 43 |
+
Wav2Vec2ASRBundle,
|
| 44 |
+
Wav2Vec2Bundle,
|
| 45 |
+
Wav2Vec2FABundle,
|
| 46 |
+
WAVLM_BASE,
|
| 47 |
+
WAVLM_BASE_PLUS,
|
| 48 |
+
WAVLM_LARGE,
|
| 49 |
+
)
|
| 50 |
+
from .rnnt_pipeline import EMFORMER_RNNT_BASE_LIBRISPEECH, RNNTBundle
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = [
|
| 54 |
+
"Wav2Vec2Bundle",
|
| 55 |
+
"Wav2Vec2ASRBundle",
|
| 56 |
+
"Wav2Vec2FABundle",
|
| 57 |
+
"WAV2VEC2_BASE",
|
| 58 |
+
"WAV2VEC2_LARGE",
|
| 59 |
+
"WAV2VEC2_LARGE_LV60K",
|
| 60 |
+
"WAV2VEC2_ASR_BASE_10M",
|
| 61 |
+
"WAV2VEC2_ASR_BASE_100H",
|
| 62 |
+
"WAV2VEC2_ASR_BASE_960H",
|
| 63 |
+
"WAV2VEC2_ASR_LARGE_10M",
|
| 64 |
+
"WAV2VEC2_ASR_LARGE_100H",
|
| 65 |
+
"WAV2VEC2_ASR_LARGE_960H",
|
| 66 |
+
"WAV2VEC2_ASR_LARGE_LV60K_10M",
|
| 67 |
+
"WAV2VEC2_ASR_LARGE_LV60K_100H",
|
| 68 |
+
"WAV2VEC2_ASR_LARGE_LV60K_960H",
|
| 69 |
+
"WAV2VEC2_XLSR53",
|
| 70 |
+
"WAV2VEC2_XLSR_300M",
|
| 71 |
+
"WAV2VEC2_XLSR_1B",
|
| 72 |
+
"WAV2VEC2_XLSR_2B",
|
| 73 |
+
"VOXPOPULI_ASR_BASE_10K_EN",
|
| 74 |
+
"VOXPOPULI_ASR_BASE_10K_ES",
|
| 75 |
+
"VOXPOPULI_ASR_BASE_10K_DE",
|
| 76 |
+
"VOXPOPULI_ASR_BASE_10K_FR",
|
| 77 |
+
"VOXPOPULI_ASR_BASE_10K_IT",
|
| 78 |
+
"HUBERT_BASE",
|
| 79 |
+
"HUBERT_LARGE",
|
| 80 |
+
"HUBERT_XLARGE",
|
| 81 |
+
"HUBERT_ASR_LARGE",
|
| 82 |
+
"HUBERT_ASR_XLARGE",
|
| 83 |
+
"MMS_FA",
|
| 84 |
+
"WAVLM_BASE",
|
| 85 |
+
"WAVLM_BASE_PLUS",
|
| 86 |
+
"WAVLM_LARGE",
|
| 87 |
+
"Tacotron2TTSBundle",
|
| 88 |
+
"TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH",
|
| 89 |
+
"TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH",
|
| 90 |
+
"TACOTRON2_WAVERNN_CHAR_LJSPEECH",
|
| 91 |
+
"TACOTRON2_WAVERNN_PHONE_LJSPEECH",
|
| 92 |
+
"RNNTBundle",
|
| 93 |
+
"EMFORMER_RNNT_BASE_LIBRISPEECH",
|
| 94 |
+
"SourceSeparationBundle",
|
| 95 |
+
"CONVTASNET_BASE_LIBRI2MIX",
|
| 96 |
+
"HDEMUCS_HIGH_MUSDB_PLUS",
|
| 97 |
+
"HDEMUCS_HIGH_MUSDB",
|
| 98 |
+
"SQUIM_OBJECTIVE",
|
| 99 |
+
"SQUIM_SUBJECTIVE",
|
| 100 |
+
"SquimObjectiveBundle",
|
| 101 |
+
"SquimSubjectiveBundle",
|
| 102 |
+
]
|
lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (2.17 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/_source_separation_pipeline.cpython-312.pyc
ADDED
|
Binary file (5.06 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/_squim_pipeline.cpython-312.pyc
ADDED
|
Binary file (7.5 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/__pycache__/rnnt_pipeline.cpython-312.pyc
ADDED
|
Binary file (20.1 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_source_separation_pipeline.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
from functools import partial
|
| 3 |
+
from typing import Callable
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
import torchaudio
|
| 7 |
+
|
| 8 |
+
from torchaudio.models import conv_tasnet_base, hdemucs_high
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@dataclass
|
| 12 |
+
class SourceSeparationBundle:
|
| 13 |
+
"""Dataclass that bundles components for performing source separation.
|
| 14 |
+
|
| 15 |
+
Example
|
| 16 |
+
>>> import torchaudio
|
| 17 |
+
>>> from torchaudio.pipelines import CONVTASNET_BASE_LIBRI2MIX
|
| 18 |
+
>>> import torch
|
| 19 |
+
>>>
|
| 20 |
+
>>> # Build the separation model.
|
| 21 |
+
>>> model = CONVTASNET_BASE_LIBRI2MIX.get_model()
|
| 22 |
+
>>> 100%|███████████████████████████████|19.1M/19.1M [00:04<00:00, 4.93MB/s]
|
| 23 |
+
>>>
|
| 24 |
+
>>> # Instantiate the test set of Libri2Mix dataset.
|
| 25 |
+
>>> dataset = torchaudio.datasets.LibriMix("/home/datasets/", subset="test")
|
| 26 |
+
>>>
|
| 27 |
+
>>> # Apply source separation on mixture audio.
|
| 28 |
+
>>> for i, data in enumerate(dataset):
|
| 29 |
+
>>> sample_rate, mixture, clean_sources = data
|
| 30 |
+
>>> # Make sure the shape of input suits the model requirement.
|
| 31 |
+
>>> mixture = mixture.reshape(1, 1, -1)
|
| 32 |
+
>>> estimated_sources = model(mixture)
|
| 33 |
+
>>> score = si_snr_pit(estimated_sources, clean_sources) # for demonstration
|
| 34 |
+
>>> print(f"Si-SNR score is : {score}.)
|
| 35 |
+
>>> break
|
| 36 |
+
>>> Si-SNR score is : 16.24.
|
| 37 |
+
>>>
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
_model_path: str
|
| 41 |
+
_model_factory_func: Callable[[], torch.nn.Module]
|
| 42 |
+
_sample_rate: int
|
| 43 |
+
|
| 44 |
+
@property
|
| 45 |
+
def sample_rate(self) -> int:
|
| 46 |
+
"""Sample rate of the audio that the model is trained on.
|
| 47 |
+
|
| 48 |
+
:type: int
|
| 49 |
+
"""
|
| 50 |
+
return self._sample_rate
|
| 51 |
+
|
| 52 |
+
def get_model(self) -> torch.nn.Module:
|
| 53 |
+
"""Construct the model and load the pretrained weight."""
|
| 54 |
+
model = self._model_factory_func()
|
| 55 |
+
path = torchaudio.utils.download_asset(self._model_path)
|
| 56 |
+
state_dict = torch.load(path)
|
| 57 |
+
model.load_state_dict(state_dict)
|
| 58 |
+
model.eval()
|
| 59 |
+
return model
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
CONVTASNET_BASE_LIBRI2MIX = SourceSeparationBundle(
|
| 63 |
+
_model_path="models/conv_tasnet_base_libri2mix.pt",
|
| 64 |
+
_model_factory_func=partial(conv_tasnet_base, num_sources=2),
|
| 65 |
+
_sample_rate=8000,
|
| 66 |
+
)
|
| 67 |
+
CONVTASNET_BASE_LIBRI2MIX.__doc__ = """Pre-trained Source Separation pipeline with *ConvTasNet*
|
| 68 |
+
:cite:`Luo_2019` trained on *Libri2Mix dataset* :cite:`cosentino2020librimix`.
|
| 69 |
+
|
| 70 |
+
The source separation model is constructed by :func:`~torchaudio.models.conv_tasnet_base`
|
| 71 |
+
and is trained using the training script ``lightning_train.py``
|
| 72 |
+
`here <https://github.com/pytorch/audio/tree/release/0.12/examples/source_separation/>`__
|
| 73 |
+
with default arguments.
|
| 74 |
+
|
| 75 |
+
Please refer to :class:`SourceSeparationBundle` for usage instructions.
|
| 76 |
+
"""
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
HDEMUCS_HIGH_MUSDB_PLUS = SourceSeparationBundle(
|
| 80 |
+
_model_path="models/hdemucs_high_trained.pt",
|
| 81 |
+
_model_factory_func=partial(hdemucs_high, sources=["drums", "bass", "other", "vocals"]),
|
| 82 |
+
_sample_rate=44100,
|
| 83 |
+
)
|
| 84 |
+
HDEMUCS_HIGH_MUSDB_PLUS.__doc__ = """Pre-trained music source separation pipeline with
|
| 85 |
+
*Hybrid Demucs* :cite:`defossez2021hybrid` trained on both training and test sets of
|
| 86 |
+
MUSDB-HQ :cite:`MUSDB18HQ` and an additional 150 extra songs from an internal database
|
| 87 |
+
that was specifically produced for Meta.
|
| 88 |
+
|
| 89 |
+
The model is constructed by :func:`~torchaudio.models.hdemucs_high`.
|
| 90 |
+
|
| 91 |
+
Training was performed in the original HDemucs repository `here <https://github.com/facebookresearch/demucs/>`__.
|
| 92 |
+
|
| 93 |
+
Please refer to :class:`SourceSeparationBundle` for usage instructions.
|
| 94 |
+
"""
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
HDEMUCS_HIGH_MUSDB = SourceSeparationBundle(
|
| 98 |
+
_model_path="models/hdemucs_high_musdbhq_only.pt",
|
| 99 |
+
_model_factory_func=partial(hdemucs_high, sources=["drums", "bass", "other", "vocals"]),
|
| 100 |
+
_sample_rate=44100,
|
| 101 |
+
)
|
| 102 |
+
HDEMUCS_HIGH_MUSDB.__doc__ = """Pre-trained music source separation pipeline with
|
| 103 |
+
*Hybrid Demucs* :cite:`defossez2021hybrid` trained on the training set of MUSDB-HQ :cite:`MUSDB18HQ`.
|
| 104 |
+
|
| 105 |
+
The model is constructed by :func:`~torchaudio.models.hdemucs_high`.
|
| 106 |
+
Training was performed in the original HDemucs repository `here <https://github.com/facebookresearch/demucs/>`__.
|
| 107 |
+
|
| 108 |
+
Please refer to :class:`SourceSeparationBundle` for usage instructions.
|
| 109 |
+
"""
|
lib/python3.12/site-packages/torchaudio/pipelines/_squim_pipeline.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
import torchaudio
|
| 5 |
+
|
| 6 |
+
from torchaudio.models import squim_objective_base, squim_subjective_base, SquimObjective, SquimSubjective
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class SquimObjectiveBundle:
|
| 11 |
+
"""Data class that bundles associated information to use pretrained
|
| 12 |
+
:py:class:`~torchaudio.models.SquimObjective` model.
|
| 13 |
+
|
| 14 |
+
This class provides interfaces for instantiating the pretrained model along with
|
| 15 |
+
the information necessary to retrieve pretrained weights and additional data
|
| 16 |
+
to be used with the model.
|
| 17 |
+
|
| 18 |
+
Torchaudio library instantiates objects of this class, each of which represents
|
| 19 |
+
a different pretrained model. Client code should access pretrained models via these
|
| 20 |
+
instances.
|
| 21 |
+
|
| 22 |
+
This bundle can estimate objective metric scores for speech enhancement, such as STOI, PESQ, Si-SDR.
|
| 23 |
+
A typical use case would be a flow like `waveform -> list of scores`. Please see below for the code example.
|
| 24 |
+
|
| 25 |
+
Example: Estimate the objective metric scores for the input waveform.
|
| 26 |
+
>>> import torch
|
| 27 |
+
>>> import torchaudio
|
| 28 |
+
>>> from torchaudio.pipelines import SQUIM_OBJECTIVE as bundle
|
| 29 |
+
>>>
|
| 30 |
+
>>> # Load the SquimObjective bundle
|
| 31 |
+
>>> model = bundle.get_model()
|
| 32 |
+
Downloading: "https://download.pytorch.org/torchaudio/models/squim_objective_dns2020.pth"
|
| 33 |
+
100%|████████████| 28.2M/28.2M [00:03<00:00, 9.24MB/s]
|
| 34 |
+
>>>
|
| 35 |
+
>>> # Resample audio to the expected sampling rate
|
| 36 |
+
>>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate)
|
| 37 |
+
>>>
|
| 38 |
+
>>> # Estimate objective metric scores
|
| 39 |
+
>>> scores = model(waveform)
|
| 40 |
+
>>> print(f"STOI: {scores[0].item()}, PESQ: {scores[1].item()}, SI-SDR: {scores[2].item()}.")
|
| 41 |
+
""" # noqa: E501
|
| 42 |
+
|
| 43 |
+
_path: str
|
| 44 |
+
_sample_rate: float
|
| 45 |
+
|
| 46 |
+
def get_model(self) -> SquimObjective:
|
| 47 |
+
"""Construct the SquimObjective model, and load the pretrained weight.
|
| 48 |
+
|
| 49 |
+
Returns:
|
| 50 |
+
Variation of :py:class:`~torchaudio.models.SquimObjective`.
|
| 51 |
+
"""
|
| 52 |
+
model = squim_objective_base()
|
| 53 |
+
path = torchaudio.utils.download_asset(f"models/{self._path}")
|
| 54 |
+
state_dict = torch.load(path, weights_only=True)
|
| 55 |
+
model.load_state_dict(state_dict)
|
| 56 |
+
model.eval()
|
| 57 |
+
return model
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def sample_rate(self):
|
| 61 |
+
"""Sample rate of the audio that the model is trained on.
|
| 62 |
+
|
| 63 |
+
:type: float
|
| 64 |
+
"""
|
| 65 |
+
return self._sample_rate
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
SQUIM_OBJECTIVE = SquimObjectiveBundle(
|
| 69 |
+
"squim_objective_dns2020.pth",
|
| 70 |
+
_sample_rate=16000,
|
| 71 |
+
)
|
| 72 |
+
SQUIM_OBJECTIVE.__doc__ = """SquimObjective pipeline trained using approach described in
|
| 73 |
+
:cite:`kumar2023torchaudio` on the *DNS 2020 Dataset* :cite:`reddy2020interspeech`.
|
| 74 |
+
|
| 75 |
+
The underlying model is constructed by :py:func:`torchaudio.models.squim_objective_base`.
|
| 76 |
+
The weights are under `Creative Commons Attribution 4.0 International License
|
| 77 |
+
<https://github.com/microsoft/DNS-Challenge/blob/interspeech2020/master/LICENSE>`__.
|
| 78 |
+
|
| 79 |
+
Please refer to :py:class:`SquimObjectiveBundle` for usage instructions.
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
@dataclass
|
| 84 |
+
class SquimSubjectiveBundle:
|
| 85 |
+
"""Data class that bundles associated information to use pretrained
|
| 86 |
+
:py:class:`~torchaudio.models.SquimSubjective` model.
|
| 87 |
+
|
| 88 |
+
This class provides interfaces for instantiating the pretrained model along with
|
| 89 |
+
the information necessary to retrieve pretrained weights and additional data
|
| 90 |
+
to be used with the model.
|
| 91 |
+
|
| 92 |
+
Torchaudio library instantiates objects of this class, each of which represents
|
| 93 |
+
a different pretrained model. Client code should access pretrained models via these
|
| 94 |
+
instances.
|
| 95 |
+
|
| 96 |
+
This bundle can estimate subjective metric scores for speech enhancement, such as MOS.
|
| 97 |
+
A typical use case would be a flow like `waveform -> score`. Please see below for the code example.
|
| 98 |
+
|
| 99 |
+
Example: Estimate the subjective metric scores for the input waveform.
|
| 100 |
+
>>> import torch
|
| 101 |
+
>>> import torchaudio
|
| 102 |
+
>>> from torchaudio.pipelines import SQUIM_SUBJECTIVE as bundle
|
| 103 |
+
>>>
|
| 104 |
+
>>> # Load the SquimSubjective bundle
|
| 105 |
+
>>> model = bundle.get_model()
|
| 106 |
+
Downloading: "https://download.pytorch.org/torchaudio/models/squim_subjective_bvcc_daps.pth"
|
| 107 |
+
100%|████████████| 360M/360M [00:09<00:00, 41.1MB/s]
|
| 108 |
+
>>>
|
| 109 |
+
>>> # Resample audio to the expected sampling rate
|
| 110 |
+
>>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate)
|
| 111 |
+
>>> # Use a clean reference (doesn't need to be the reference for the waveform) as the second input
|
| 112 |
+
>>> reference = torchaudio.functional.resample(reference, sample_rate, bundle.sample_rate)
|
| 113 |
+
>>>
|
| 114 |
+
>>> # Estimate subjective metric scores
|
| 115 |
+
>>> score = model(waveform, reference)
|
| 116 |
+
>>> print(f"MOS: {score}.")
|
| 117 |
+
""" # noqa: E501
|
| 118 |
+
|
| 119 |
+
_path: str
|
| 120 |
+
_sample_rate: float
|
| 121 |
+
|
| 122 |
+
def get_model(self) -> SquimSubjective:
|
| 123 |
+
"""Construct the SquimSubjective model, and load the pretrained weight.
|
| 124 |
+
Returns:
|
| 125 |
+
Variation of :py:class:`~torchaudio.models.SquimObjective`.
|
| 126 |
+
"""
|
| 127 |
+
model = squim_subjective_base()
|
| 128 |
+
path = torchaudio.utils.download_asset(f"models/{self._path}")
|
| 129 |
+
state_dict = torch.load(path, weights_only=True)
|
| 130 |
+
model.load_state_dict(state_dict)
|
| 131 |
+
model.eval()
|
| 132 |
+
return model
|
| 133 |
+
|
| 134 |
+
@property
|
| 135 |
+
def sample_rate(self):
|
| 136 |
+
"""Sample rate of the audio that the model is trained on.
|
| 137 |
+
|
| 138 |
+
:type: float
|
| 139 |
+
"""
|
| 140 |
+
return self._sample_rate
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
SQUIM_SUBJECTIVE = SquimSubjectiveBundle(
|
| 144 |
+
"squim_subjective_bvcc_daps.pth",
|
| 145 |
+
_sample_rate=16000,
|
| 146 |
+
)
|
| 147 |
+
SQUIM_SUBJECTIVE.__doc__ = """SquimSubjective pipeline trained
|
| 148 |
+
as described in :cite:`manocha2022speech` and :cite:`kumar2023torchaudio`
|
| 149 |
+
on the *BVCC* :cite:`cooper2021voices` and *DAPS* :cite:`mysore2014can` datasets.
|
| 150 |
+
|
| 151 |
+
The underlying model is constructed by :py:func:`torchaudio.models.squim_subjective_base`.
|
| 152 |
+
The weights are under `Creative Commons Attribution Non Commercial 4.0 International
|
| 153 |
+
<https://zenodo.org/record/4660670#.ZBtWPOxuerN>`__.
|
| 154 |
+
|
| 155 |
+
Please refer to :py:class:`SquimSubjectiveBundle` for usage instructions.
|
| 156 |
+
"""
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .impl import (
|
| 2 |
+
TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH,
|
| 3 |
+
TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH,
|
| 4 |
+
TACOTRON2_WAVERNN_CHAR_LJSPEECH,
|
| 5 |
+
TACOTRON2_WAVERNN_PHONE_LJSPEECH,
|
| 6 |
+
)
|
| 7 |
+
from .interface import Tacotron2TTSBundle
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
__all__ = [
|
| 11 |
+
"Tacotron2TTSBundle",
|
| 12 |
+
"TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH",
|
| 13 |
+
"TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH",
|
| 14 |
+
"TACOTRON2_WAVERNN_CHAR_LJSPEECH",
|
| 15 |
+
"TACOTRON2_WAVERNN_PHONE_LJSPEECH",
|
| 16 |
+
]
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (514 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/impl.cpython-312.pyc
ADDED
|
Binary file (19.8 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/interface.cpython-312.pyc
ADDED
|
Binary file (11.6 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (5.12 kB). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/impl.py
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
from torch import Tensor
|
| 7 |
+
from torchaudio._internal import load_state_dict_from_url
|
| 8 |
+
from torchaudio.functional import mu_law_decoding
|
| 9 |
+
from torchaudio.models import Tacotron2, WaveRNN
|
| 10 |
+
from torchaudio.transforms import GriffinLim, InverseMelScale
|
| 11 |
+
|
| 12 |
+
from . import utils
|
| 13 |
+
from .interface import Tacotron2TTSBundle
|
| 14 |
+
|
| 15 |
+
__all__ = []
|
| 16 |
+
|
| 17 |
+
_BASE_URL = "https://download.pytorch.org/torchaudio/models"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
################################################################################
|
| 21 |
+
# Pipeline implementation - Text Processor
|
| 22 |
+
################################################################################
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class _EnglishCharProcessor(Tacotron2TTSBundle.TextProcessor):
|
| 26 |
+
def __init__(self):
|
| 27 |
+
super().__init__()
|
| 28 |
+
self._tokens = utils._get_chars()
|
| 29 |
+
self._mapping = {s: i for i, s in enumerate(self._tokens)}
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def tokens(self):
|
| 33 |
+
return self._tokens
|
| 34 |
+
|
| 35 |
+
def __call__(self, texts: Union[str, List[str]]) -> Tuple[Tensor, Tensor]:
|
| 36 |
+
if isinstance(texts, str):
|
| 37 |
+
texts = [texts]
|
| 38 |
+
indices = [[self._mapping[c] for c in t.lower() if c in self._mapping] for t in texts]
|
| 39 |
+
return utils._to_tensor(indices)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class _EnglishPhoneProcessor(Tacotron2TTSBundle.TextProcessor):
|
| 43 |
+
def __init__(self, *, dl_kwargs=None):
|
| 44 |
+
super().__init__()
|
| 45 |
+
self._tokens = utils._get_phones()
|
| 46 |
+
self._mapping = {p: i for i, p in enumerate(self._tokens)}
|
| 47 |
+
self._phonemizer = utils._load_phonemizer("en_us_cmudict_forward.pt", dl_kwargs=dl_kwargs)
|
| 48 |
+
self._pattern = r"(\[[A-Z]+?\]|[_!'(),.:;? -])"
|
| 49 |
+
|
| 50 |
+
@property
|
| 51 |
+
def tokens(self):
|
| 52 |
+
return self._tokens
|
| 53 |
+
|
| 54 |
+
def __call__(self, texts: Union[str, List[str]]) -> Tuple[Tensor, Tensor]:
|
| 55 |
+
if isinstance(texts, str):
|
| 56 |
+
texts = [texts]
|
| 57 |
+
|
| 58 |
+
indices = []
|
| 59 |
+
for phones in self._phonemizer(texts, lang="en_us"):
|
| 60 |
+
# '[F][UW][B][AA][R]!' -> ['F', 'UW', 'B', 'AA', 'R', '!']
|
| 61 |
+
ret = [re.sub(r"[\[\]]", "", r) for r in re.findall(self._pattern, phones)]
|
| 62 |
+
indices.append([self._mapping[p] for p in ret])
|
| 63 |
+
return utils._to_tensor(indices)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
################################################################################
|
| 67 |
+
# Pipeline implementation - Vocoder
|
| 68 |
+
################################################################################
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class _WaveRNNVocoder(torch.nn.Module, Tacotron2TTSBundle.Vocoder):
|
| 72 |
+
def __init__(self, model: WaveRNN, min_level_db: Optional[float] = -100):
|
| 73 |
+
super().__init__()
|
| 74 |
+
self._sample_rate = 22050
|
| 75 |
+
self._model = model
|
| 76 |
+
self._min_level_db = min_level_db
|
| 77 |
+
|
| 78 |
+
@property
|
| 79 |
+
def sample_rate(self):
|
| 80 |
+
return self._sample_rate
|
| 81 |
+
|
| 82 |
+
def forward(self, mel_spec, lengths=None):
|
| 83 |
+
mel_spec = torch.exp(mel_spec)
|
| 84 |
+
mel_spec = 20 * torch.log10(torch.clamp(mel_spec, min=1e-5))
|
| 85 |
+
if self._min_level_db is not None:
|
| 86 |
+
mel_spec = (self._min_level_db - mel_spec) / self._min_level_db
|
| 87 |
+
mel_spec = torch.clamp(mel_spec, min=0, max=1)
|
| 88 |
+
waveform, lengths = self._model.infer(mel_spec, lengths)
|
| 89 |
+
waveform = utils._unnormalize_waveform(waveform, self._model.n_bits)
|
| 90 |
+
waveform = mu_law_decoding(waveform, self._model.n_classes)
|
| 91 |
+
waveform = waveform.squeeze(1)
|
| 92 |
+
return waveform, lengths
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
class _GriffinLimVocoder(torch.nn.Module, Tacotron2TTSBundle.Vocoder):
|
| 96 |
+
def __init__(self):
|
| 97 |
+
super().__init__()
|
| 98 |
+
self._sample_rate = 22050
|
| 99 |
+
self._inv_mel = InverseMelScale(
|
| 100 |
+
n_stft=(1024 // 2 + 1),
|
| 101 |
+
n_mels=80,
|
| 102 |
+
sample_rate=self.sample_rate,
|
| 103 |
+
f_min=0.0,
|
| 104 |
+
f_max=8000.0,
|
| 105 |
+
mel_scale="slaney",
|
| 106 |
+
norm="slaney",
|
| 107 |
+
)
|
| 108 |
+
self._griffin_lim = GriffinLim(
|
| 109 |
+
n_fft=1024,
|
| 110 |
+
power=1,
|
| 111 |
+
hop_length=256,
|
| 112 |
+
win_length=1024,
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
@property
|
| 116 |
+
def sample_rate(self):
|
| 117 |
+
return self._sample_rate
|
| 118 |
+
|
| 119 |
+
def forward(self, mel_spec, lengths=None):
|
| 120 |
+
mel_spec = torch.exp(mel_spec)
|
| 121 |
+
mel_spec = mel_spec.clone().detach().requires_grad_(True)
|
| 122 |
+
spec = self._inv_mel(mel_spec)
|
| 123 |
+
spec = spec.detach().requires_grad_(False)
|
| 124 |
+
waveforms = self._griffin_lim(spec)
|
| 125 |
+
return waveforms, lengths
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
################################################################################
|
| 129 |
+
# Bundle classes mixins
|
| 130 |
+
################################################################################
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
class _CharMixin:
|
| 134 |
+
def get_text_processor(self) -> Tacotron2TTSBundle.TextProcessor:
|
| 135 |
+
return _EnglishCharProcessor()
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
class _PhoneMixin:
|
| 139 |
+
def get_text_processor(self, *, dl_kwargs=None) -> Tacotron2TTSBundle.TextProcessor:
|
| 140 |
+
return _EnglishPhoneProcessor(dl_kwargs=dl_kwargs)
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
@dataclass
|
| 144 |
+
class _Tacotron2Mixin:
|
| 145 |
+
_tacotron2_path: str
|
| 146 |
+
_tacotron2_params: Dict[str, Any]
|
| 147 |
+
|
| 148 |
+
def get_tacotron2(self, *, dl_kwargs=None) -> Tacotron2:
|
| 149 |
+
model = Tacotron2(**self._tacotron2_params)
|
| 150 |
+
url = f"{_BASE_URL}/{self._tacotron2_path}"
|
| 151 |
+
dl_kwargs = {} if dl_kwargs is None else dl_kwargs
|
| 152 |
+
state_dict = load_state_dict_from_url(url, **dl_kwargs)
|
| 153 |
+
model.load_state_dict(state_dict)
|
| 154 |
+
model.eval()
|
| 155 |
+
return model
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
@dataclass
|
| 159 |
+
class _WaveRNNMixin:
|
| 160 |
+
_wavernn_path: Optional[str]
|
| 161 |
+
_wavernn_params: Optional[Dict[str, Any]]
|
| 162 |
+
|
| 163 |
+
def get_vocoder(self, *, dl_kwargs=None):
|
| 164 |
+
wavernn = self._get_wavernn(dl_kwargs=dl_kwargs)
|
| 165 |
+
return _WaveRNNVocoder(wavernn)
|
| 166 |
+
|
| 167 |
+
def _get_wavernn(self, *, dl_kwargs=None):
|
| 168 |
+
model = WaveRNN(**self._wavernn_params)
|
| 169 |
+
url = f"{_BASE_URL}/{self._wavernn_path}"
|
| 170 |
+
dl_kwargs = {} if dl_kwargs is None else dl_kwargs
|
| 171 |
+
state_dict = load_state_dict_from_url(url, **dl_kwargs)
|
| 172 |
+
model.load_state_dict(state_dict)
|
| 173 |
+
model.eval()
|
| 174 |
+
return model
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
class _GriffinLimMixin:
|
| 178 |
+
def get_vocoder(self, **_):
|
| 179 |
+
return _GriffinLimVocoder()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
################################################################################
|
| 183 |
+
# Bundle classes
|
| 184 |
+
################################################################################
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
@dataclass
|
| 188 |
+
class _Tacotron2WaveRNNCharBundle(_WaveRNNMixin, _Tacotron2Mixin, _CharMixin, Tacotron2TTSBundle):
|
| 189 |
+
pass
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
@dataclass
|
| 193 |
+
class _Tacotron2WaveRNNPhoneBundle(_WaveRNNMixin, _Tacotron2Mixin, _PhoneMixin, Tacotron2TTSBundle):
|
| 194 |
+
pass
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
@dataclass
|
| 198 |
+
class _Tacotron2GriffinLimCharBundle(_GriffinLimMixin, _Tacotron2Mixin, _CharMixin, Tacotron2TTSBundle):
|
| 199 |
+
pass
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
@dataclass
|
| 203 |
+
class _Tacotron2GriffinLimPhoneBundle(_GriffinLimMixin, _Tacotron2Mixin, _PhoneMixin, Tacotron2TTSBundle):
|
| 204 |
+
pass
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
################################################################################
|
| 208 |
+
# Instantiate bundle objects
|
| 209 |
+
################################################################################
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH = _Tacotron2GriffinLimCharBundle(
|
| 213 |
+
_tacotron2_path="tacotron2_english_characters_1500_epochs_ljspeech.pth",
|
| 214 |
+
_tacotron2_params=utils._get_taco_params(n_symbols=38),
|
| 215 |
+
)
|
| 216 |
+
TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH.__doc__ = """Character-based TTS pipeline with :py:class:`~torchaudio.models.Tacotron2` trained on *LJSpeech* :cite:`ljspeech17` for 1,500 epochs, and
|
| 217 |
+
:py:class:`~torchaudio.transforms.GriffinLim` as vocoder.
|
| 218 |
+
|
| 219 |
+
The text processor encodes the input texts character-by-character.
|
| 220 |
+
|
| 221 |
+
You can find the training script `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_tacotron2>`__.
|
| 222 |
+
The default parameters were used.
|
| 223 |
+
|
| 224 |
+
Please refer to :func:`torchaudio.pipelines.Tacotron2TTSBundle` for the usage.
|
| 225 |
+
|
| 226 |
+
Example - "Hello world! T T S stands for Text to Speech!"
|
| 227 |
+
|
| 228 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH.png
|
| 229 |
+
:alt: Spectrogram generated by Tacotron2
|
| 230 |
+
|
| 231 |
+
.. raw:: html
|
| 232 |
+
|
| 233 |
+
<audio controls="controls">
|
| 234 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH.wav" type="audio/wav">
|
| 235 |
+
Your browser does not support the <code>audio</code> element.
|
| 236 |
+
</audio>
|
| 237 |
+
|
| 238 |
+
Example - "The examination and testimony of the experts enabled the Commission to conclude that five shots may have been fired,"
|
| 239 |
+
|
| 240 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH_v2.png
|
| 241 |
+
:alt: Spectrogram generated by Tacotron2
|
| 242 |
+
|
| 243 |
+
.. raw:: html
|
| 244 |
+
|
| 245 |
+
<audio controls="controls">
|
| 246 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH_v2.wav" type="audio/wav">
|
| 247 |
+
Your browser does not support the <code>audio</code> element.
|
| 248 |
+
</audio>
|
| 249 |
+
""" # noqa: E501
|
| 250 |
+
|
| 251 |
+
TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH = _Tacotron2GriffinLimPhoneBundle(
|
| 252 |
+
_tacotron2_path="tacotron2_english_phonemes_1500_epochs_ljspeech.pth",
|
| 253 |
+
_tacotron2_params=utils._get_taco_params(n_symbols=96),
|
| 254 |
+
)
|
| 255 |
+
TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH.__doc__ = """Phoneme-based TTS pipeline with :py:class:`~torchaudio.models.Tacotron2` trained on *LJSpeech* :cite:`ljspeech17` for 1,500 epochs and
|
| 256 |
+
:py:class:`~torchaudio.transforms.GriffinLim` as vocoder.
|
| 257 |
+
|
| 258 |
+
The text processor encodes the input texts based on phoneme.
|
| 259 |
+
It uses `DeepPhonemizer <https://github.com/as-ideas/DeepPhonemizer>`__ to convert
|
| 260 |
+
graphemes to phonemes.
|
| 261 |
+
The model (*en_us_cmudict_forward*) was trained on
|
| 262 |
+
`CMUDict <http://www.speech.cs.cmu.edu/cgi-bin/cmudict>`__.
|
| 263 |
+
|
| 264 |
+
You can find the training script `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_tacotron2>`__.
|
| 265 |
+
The text processor is set to the *"english_phonemes"*.
|
| 266 |
+
|
| 267 |
+
Please refer to :func:`torchaudio.pipelines.Tacotron2TTSBundle` for the usage.
|
| 268 |
+
|
| 269 |
+
Example - "Hello world! T T S stands for Text to Speech!"
|
| 270 |
+
|
| 271 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH.png
|
| 272 |
+
:alt: Spectrogram generated by Tacotron2
|
| 273 |
+
|
| 274 |
+
.. raw:: html
|
| 275 |
+
|
| 276 |
+
<audio controls="controls">
|
| 277 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH.wav" type="audio/wav">
|
| 278 |
+
Your browser does not support the <code>audio</code> element.
|
| 279 |
+
</audio>
|
| 280 |
+
|
| 281 |
+
Example - "The examination and testimony of the experts enabled the Commission to conclude that five shots may have been fired,"
|
| 282 |
+
|
| 283 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH_v2.png
|
| 284 |
+
:alt: Spectrogram generated by Tacotron2
|
| 285 |
+
|
| 286 |
+
.. raw:: html
|
| 287 |
+
|
| 288 |
+
<audio controls="controls">
|
| 289 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH_v2.wav" type="audio/wav">
|
| 290 |
+
Your browser does not support the <code>audio</code> element.
|
| 291 |
+
</audio>
|
| 292 |
+
|
| 293 |
+
""" # noqa: E501
|
| 294 |
+
|
| 295 |
+
TACOTRON2_WAVERNN_CHAR_LJSPEECH = _Tacotron2WaveRNNCharBundle(
|
| 296 |
+
_tacotron2_path="tacotron2_english_characters_1500_epochs_wavernn_ljspeech.pth",
|
| 297 |
+
_tacotron2_params=utils._get_taco_params(n_symbols=38),
|
| 298 |
+
_wavernn_path="wavernn_10k_epochs_8bits_ljspeech.pth",
|
| 299 |
+
_wavernn_params=utils._get_wrnn_params(),
|
| 300 |
+
)
|
| 301 |
+
TACOTRON2_WAVERNN_CHAR_LJSPEECH.__doc__ = """Character-based TTS pipeline with :py:class:`~torchaudio.models.Tacotron2` trained on *LJSpeech* :cite:`ljspeech17` for 1,500 epochs and :py:class:`~torchaudio.models.WaveRNN` vocoder trained on 8 bits depth waveform of *LJSpeech* :cite:`ljspeech17` for 10,000 epochs.
|
| 302 |
+
|
| 303 |
+
The text processor encodes the input texts character-by-character.
|
| 304 |
+
|
| 305 |
+
You can find the training script `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_tacotron2>`__.
|
| 306 |
+
The following parameters were used; ``win_length=1100``, ``hop_length=275``, ``n_fft=2048``,
|
| 307 |
+
``mel_fmin=40``, and ``mel_fmax=11025``.
|
| 308 |
+
|
| 309 |
+
You can find the training script `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_wavernn>`__.
|
| 310 |
+
|
| 311 |
+
Please refer to :func:`torchaudio.pipelines.Tacotron2TTSBundle` for the usage.
|
| 312 |
+
|
| 313 |
+
Example - "Hello world! T T S stands for Text to Speech!"
|
| 314 |
+
|
| 315 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_CHAR_LJSPEECH.png
|
| 316 |
+
:alt: Spectrogram generated by Tacotron2
|
| 317 |
+
|
| 318 |
+
.. raw:: html
|
| 319 |
+
|
| 320 |
+
<audio controls="controls">
|
| 321 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_CHAR_LJSPEECH.wav" type="audio/wav">
|
| 322 |
+
Your browser does not support the <code>audio</code> element.
|
| 323 |
+
</audio>
|
| 324 |
+
|
| 325 |
+
Example - "The examination and testimony of the experts enabled the Commission to conclude that five shots may have been fired,"
|
| 326 |
+
|
| 327 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_CHAR_LJSPEECH_v2.png
|
| 328 |
+
:alt: Spectrogram generated by Tacotron2
|
| 329 |
+
|
| 330 |
+
.. raw:: html
|
| 331 |
+
|
| 332 |
+
<audio controls="controls">
|
| 333 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_CHAR_LJSPEECH_v2.wav" type="audio/wav">
|
| 334 |
+
Your browser does not support the <code>audio</code> element.
|
| 335 |
+
</audio>
|
| 336 |
+
""" # noqa: E501
|
| 337 |
+
|
| 338 |
+
TACOTRON2_WAVERNN_PHONE_LJSPEECH = _Tacotron2WaveRNNPhoneBundle(
|
| 339 |
+
_tacotron2_path="tacotron2_english_phonemes_1500_epochs_wavernn_ljspeech.pth",
|
| 340 |
+
_tacotron2_params=utils._get_taco_params(n_symbols=96),
|
| 341 |
+
_wavernn_path="wavernn_10k_epochs_8bits_ljspeech.pth",
|
| 342 |
+
_wavernn_params=utils._get_wrnn_params(),
|
| 343 |
+
)
|
| 344 |
+
TACOTRON2_WAVERNN_PHONE_LJSPEECH.__doc__ = """Phoneme-based TTS pipeline with :py:class:`~torchaudio.models.Tacotron2` trained on *LJSpeech* :cite:`ljspeech17` for 1,500 epochs, and
|
| 345 |
+
:py:class:`~torchaudio.models.WaveRNN` vocoder trained on 8 bits depth waveform of *LJSpeech* :cite:`ljspeech17` for 10,000 epochs.
|
| 346 |
+
|
| 347 |
+
The text processor encodes the input texts based on phoneme.
|
| 348 |
+
It uses `DeepPhonemizer <https://github.com/as-ideas/DeepPhonemizer>`__ to convert
|
| 349 |
+
graphemes to phonemes.
|
| 350 |
+
The model (*en_us_cmudict_forward*) was trained on
|
| 351 |
+
`CMUDict <http://www.speech.cs.cmu.edu/cgi-bin/cmudict>`__.
|
| 352 |
+
|
| 353 |
+
You can find the training script for Tacotron2 `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_tacotron2>`__.
|
| 354 |
+
The following parameters were used; ``win_length=1100``, ``hop_length=275``, ``n_fft=2048``,
|
| 355 |
+
``mel_fmin=40``, and ``mel_fmax=11025``.
|
| 356 |
+
|
| 357 |
+
You can find the training script for WaveRNN `here <https://github.com/pytorch/audio/tree/main/examples/pipeline_wavernn>`__.
|
| 358 |
+
|
| 359 |
+
Please refer to :func:`torchaudio.pipelines.Tacotron2TTSBundle` for the usage.
|
| 360 |
+
|
| 361 |
+
Example - "Hello world! T T S stands for Text to Speech!"
|
| 362 |
+
|
| 363 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_PHONE_LJSPEECH.png
|
| 364 |
+
:alt: Spectrogram generated by Tacotron2
|
| 365 |
+
|
| 366 |
+
.. raw:: html
|
| 367 |
+
|
| 368 |
+
<audio controls="controls">
|
| 369 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_PHONE_LJSPEECH.wav" type="audio/wav">
|
| 370 |
+
Your browser does not support the <code>audio</code> element.
|
| 371 |
+
</audio>
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
Example - "The examination and testimony of the experts enabled the Commission to conclude that five shots may have been fired,"
|
| 375 |
+
|
| 376 |
+
.. image:: https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_PHONE_LJSPEECH_v2.png
|
| 377 |
+
:alt: Spectrogram generated by Tacotron2
|
| 378 |
+
|
| 379 |
+
.. raw:: html
|
| 380 |
+
|
| 381 |
+
<audio controls="controls">
|
| 382 |
+
<source src="https://download.pytorch.org/torchaudio/doc-assets/TACOTRON2_WAVERNN_PHONE_LJSPEECH_v2.wav" type="audio/wav">
|
| 383 |
+
Your browser does not support the <code>audio</code> element.
|
| 384 |
+
</audio>
|
| 385 |
+
""" # noqa: E501
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/interface.py
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
from typing import List, Optional, Tuple, Union
|
| 3 |
+
|
| 4 |
+
from torch import Tensor
|
| 5 |
+
from torchaudio.models import Tacotron2
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class _TextProcessor(ABC):
|
| 9 |
+
@property
|
| 10 |
+
@abstractmethod
|
| 11 |
+
def tokens(self):
|
| 12 |
+
"""The tokens that the each value in the processed tensor represent.
|
| 13 |
+
|
| 14 |
+
:type: List[str]
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
@abstractmethod
|
| 18 |
+
def __call__(self, texts: Union[str, List[str]]) -> Tuple[Tensor, Tensor]:
|
| 19 |
+
"""Encode the given (batch of) texts into numerical tensors
|
| 20 |
+
|
| 21 |
+
Args:
|
| 22 |
+
text (str or list of str): The input texts.
|
| 23 |
+
|
| 24 |
+
Returns:
|
| 25 |
+
(Tensor, Tensor):
|
| 26 |
+
Tensor:
|
| 27 |
+
The encoded texts. Shape: `(batch, max length)`
|
| 28 |
+
Tensor:
|
| 29 |
+
The valid length of each sample in the batch. Shape: `(batch, )`.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class _Vocoder(ABC):
|
| 34 |
+
@property
|
| 35 |
+
@abstractmethod
|
| 36 |
+
def sample_rate(self):
|
| 37 |
+
"""The sample rate of the resulting waveform
|
| 38 |
+
|
| 39 |
+
:type: float
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
@abstractmethod
|
| 43 |
+
def __call__(self, specgrams: Tensor, lengths: Optional[Tensor] = None) -> Tuple[Tensor, Optional[Tensor]]:
|
| 44 |
+
"""Generate waveform from the given input, such as spectrogram
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
specgrams (Tensor):
|
| 48 |
+
The input spectrogram. Shape: `(batch, frequency bins, time)`.
|
| 49 |
+
The expected shape depends on the implementation.
|
| 50 |
+
lengths (Tensor, or None, optional):
|
| 51 |
+
The valid length of each sample in the batch. Shape: `(batch, )`.
|
| 52 |
+
(Default: `None`)
|
| 53 |
+
|
| 54 |
+
Returns:
|
| 55 |
+
(Tensor, Optional[Tensor]):
|
| 56 |
+
Tensor:
|
| 57 |
+
The generated waveform. Shape: `(batch, max length)`
|
| 58 |
+
Tensor or None:
|
| 59 |
+
The valid length of each sample in the batch. Shape: `(batch, )`.
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class Tacotron2TTSBundle(ABC):
|
| 64 |
+
"""Data class that bundles associated information to use pretrained Tacotron2 and vocoder.
|
| 65 |
+
|
| 66 |
+
This class provides interfaces for instantiating the pretrained model along with
|
| 67 |
+
the information necessary to retrieve pretrained weights and additional data
|
| 68 |
+
to be used with the model.
|
| 69 |
+
|
| 70 |
+
Torchaudio library instantiates objects of this class, each of which represents
|
| 71 |
+
a different pretrained model. Client code should access pretrained models via these
|
| 72 |
+
instances.
|
| 73 |
+
|
| 74 |
+
Please see below for the usage and the available values.
|
| 75 |
+
|
| 76 |
+
Example - Character-based TTS pipeline with Tacotron2 and WaveRNN
|
| 77 |
+
>>> import torchaudio
|
| 78 |
+
>>>
|
| 79 |
+
>>> text = "Hello, T T S !"
|
| 80 |
+
>>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_CHAR_LJSPEECH
|
| 81 |
+
>>>
|
| 82 |
+
>>> # Build processor, Tacotron2 and WaveRNN model
|
| 83 |
+
>>> processor = bundle.get_text_processor()
|
| 84 |
+
>>> tacotron2 = bundle.get_tacotron2()
|
| 85 |
+
Downloading:
|
| 86 |
+
100%|███████████████████████████████| 107M/107M [00:01<00:00, 87.9MB/s]
|
| 87 |
+
>>> vocoder = bundle.get_vocoder()
|
| 88 |
+
Downloading:
|
| 89 |
+
100%|███████████████████████████████| 16.7M/16.7M [00:00<00:00, 78.1MB/s]
|
| 90 |
+
>>>
|
| 91 |
+
>>> # Encode text
|
| 92 |
+
>>> input, lengths = processor(text)
|
| 93 |
+
>>>
|
| 94 |
+
>>> # Generate (mel-scale) spectrogram
|
| 95 |
+
>>> specgram, lengths, _ = tacotron2.infer(input, lengths)
|
| 96 |
+
>>>
|
| 97 |
+
>>> # Convert spectrogram to waveform
|
| 98 |
+
>>> waveforms, lengths = vocoder(specgram, lengths)
|
| 99 |
+
>>>
|
| 100 |
+
>>> torchaudio.save('hello-tts.wav', waveforms, vocoder.sample_rate)
|
| 101 |
+
|
| 102 |
+
Example - Phoneme-based TTS pipeline with Tacotron2 and WaveRNN
|
| 103 |
+
>>>
|
| 104 |
+
>>> # Note:
|
| 105 |
+
>>> # This bundle uses pre-trained DeepPhonemizer as
|
| 106 |
+
>>> # the text pre-processor.
|
| 107 |
+
>>> # Please install deep-phonemizer.
|
| 108 |
+
>>> # See https://github.com/as-ideas/DeepPhonemizer
|
| 109 |
+
>>> # The pretrained weight is automatically downloaded.
|
| 110 |
+
>>>
|
| 111 |
+
>>> import torchaudio
|
| 112 |
+
>>>
|
| 113 |
+
>>> text = "Hello, TTS!"
|
| 114 |
+
>>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_PHONE_LJSPEECH
|
| 115 |
+
>>>
|
| 116 |
+
>>> # Build processor, Tacotron2 and WaveRNN model
|
| 117 |
+
>>> processor = bundle.get_text_processor()
|
| 118 |
+
Downloading:
|
| 119 |
+
100%|███████████████████████████████| 63.6M/63.6M [00:04<00:00, 15.3MB/s]
|
| 120 |
+
>>> tacotron2 = bundle.get_tacotron2()
|
| 121 |
+
Downloading:
|
| 122 |
+
100%|███████████████████████████████| 107M/107M [00:01<00:00, 87.9MB/s]
|
| 123 |
+
>>> vocoder = bundle.get_vocoder()
|
| 124 |
+
Downloading:
|
| 125 |
+
100%|███████████████████████████████| 16.7M/16.7M [00:00<00:00, 78.1MB/s]
|
| 126 |
+
>>>
|
| 127 |
+
>>> # Encode text
|
| 128 |
+
>>> input, lengths = processor(text)
|
| 129 |
+
>>>
|
| 130 |
+
>>> # Generate (mel-scale) spectrogram
|
| 131 |
+
>>> specgram, lengths, _ = tacotron2.infer(input, lengths)
|
| 132 |
+
>>>
|
| 133 |
+
>>> # Convert spectrogram to waveform
|
| 134 |
+
>>> waveforms, lengths = vocoder(specgram, lengths)
|
| 135 |
+
>>>
|
| 136 |
+
>>> torchaudio.save('hello-tts.wav', waveforms, vocoder.sample_rate)
|
| 137 |
+
"""
|
| 138 |
+
|
| 139 |
+
# Using the inner class so that these interfaces are not directly exposed on
|
| 140 |
+
# `torchaudio.pipelines`, but still listed in documentation.
|
| 141 |
+
# The thing is, text processing and vocoder are generic and we do not know what kind of
|
| 142 |
+
# new text processing and vocoder will be added in the future, so we want to make these
|
| 143 |
+
# interfaces specific to this Tacotron2TTS pipeline.
|
| 144 |
+
|
| 145 |
+
class TextProcessor(_TextProcessor):
|
| 146 |
+
"""Interface of the text processing part of Tacotron2TTS pipeline
|
| 147 |
+
|
| 148 |
+
See :func:`torchaudio.pipelines.Tacotron2TTSBundle.get_text_processor` for the usage.
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
class Vocoder(_Vocoder):
|
| 152 |
+
"""Interface of the vocoder part of Tacotron2TTS pipeline
|
| 153 |
+
|
| 154 |
+
See :func:`torchaudio.pipelines.Tacotron2TTSBundle.get_vocoder` for the usage.
|
| 155 |
+
"""
|
| 156 |
+
|
| 157 |
+
@abstractmethod
|
| 158 |
+
def get_text_processor(self, *, dl_kwargs=None) -> TextProcessor:
|
| 159 |
+
"""Create a text processor
|
| 160 |
+
|
| 161 |
+
For character-based pipeline, this processor splits the input text by character.
|
| 162 |
+
For phoneme-based pipeline, this processor converts the input text (grapheme) to
|
| 163 |
+
phonemes.
|
| 164 |
+
|
| 165 |
+
If a pre-trained weight file is necessary,
|
| 166 |
+
:func:`torch.hub.download_url_to_file` is used to downloaded it.
|
| 167 |
+
|
| 168 |
+
Args:
|
| 169 |
+
dl_kwargs (dictionary of keyword arguments,):
|
| 170 |
+
Passed to :func:`torch.hub.download_url_to_file`.
|
| 171 |
+
|
| 172 |
+
Returns:
|
| 173 |
+
TextProcessor:
|
| 174 |
+
A callable which takes a string or a list of strings as input and
|
| 175 |
+
returns Tensor of encoded texts and Tensor of valid lengths.
|
| 176 |
+
The object also has ``tokens`` property, which allows to recover the
|
| 177 |
+
tokenized form.
|
| 178 |
+
|
| 179 |
+
Example - Character-based
|
| 180 |
+
>>> text = [
|
| 181 |
+
>>> "Hello World!",
|
| 182 |
+
>>> "Text-to-speech!",
|
| 183 |
+
>>> ]
|
| 184 |
+
>>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_CHAR_LJSPEECH
|
| 185 |
+
>>> processor = bundle.get_text_processor()
|
| 186 |
+
>>> input, lengths = processor(text)
|
| 187 |
+
>>>
|
| 188 |
+
>>> print(input)
|
| 189 |
+
tensor([[19, 16, 23, 23, 26, 11, 34, 26, 29, 23, 15, 2, 0, 0, 0],
|
| 190 |
+
[31, 16, 35, 31, 1, 31, 26, 1, 30, 27, 16, 16, 14, 19, 2]],
|
| 191 |
+
dtype=torch.int32)
|
| 192 |
+
>>>
|
| 193 |
+
>>> print(lengths)
|
| 194 |
+
tensor([12, 15], dtype=torch.int32)
|
| 195 |
+
>>>
|
| 196 |
+
>>> print([processor.tokens[i] for i in input[0, :lengths[0]]])
|
| 197 |
+
['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']
|
| 198 |
+
>>> print([processor.tokens[i] for i in input[1, :lengths[1]]])
|
| 199 |
+
['t', 'e', 'x', 't', '-', 't', 'o', '-', 's', 'p', 'e', 'e', 'c', 'h', '!']
|
| 200 |
+
|
| 201 |
+
Example - Phoneme-based
|
| 202 |
+
>>> text = [
|
| 203 |
+
>>> "Hello, T T S !",
|
| 204 |
+
>>> "Text-to-speech!",
|
| 205 |
+
>>> ]
|
| 206 |
+
>>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_PHONE_LJSPEECH
|
| 207 |
+
>>> processor = bundle.get_text_processor()
|
| 208 |
+
Downloading:
|
| 209 |
+
100%|███████████████████████████████| 63.6M/63.6M [00:04<00:00, 15.3MB/s]
|
| 210 |
+
>>> input, lengths = processor(text)
|
| 211 |
+
>>>
|
| 212 |
+
>>> print(input)
|
| 213 |
+
tensor([[54, 20, 65, 69, 11, 92, 44, 65, 38, 2, 0, 0, 0, 0],
|
| 214 |
+
[81, 40, 64, 79, 81, 1, 81, 20, 1, 79, 77, 59, 37, 2]],
|
| 215 |
+
dtype=torch.int32)
|
| 216 |
+
>>>
|
| 217 |
+
>>> print(lengths)
|
| 218 |
+
tensor([10, 14], dtype=torch.int32)
|
| 219 |
+
>>>
|
| 220 |
+
>>> print([processor.tokens[i] for i in input[0]])
|
| 221 |
+
['HH', 'AH', 'L', 'OW', ' ', 'W', 'ER', 'L', 'D', '!', '_', '_', '_', '_']
|
| 222 |
+
>>> print([processor.tokens[i] for i in input[1]])
|
| 223 |
+
['T', 'EH', 'K', 'S', 'T', '-', 'T', 'AH', '-', 'S', 'P', 'IY', 'CH', '!']
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
@abstractmethod
|
| 227 |
+
def get_vocoder(self, *, dl_kwargs=None) -> Vocoder:
|
| 228 |
+
"""Create a vocoder module, based off of either WaveRNN or GriffinLim.
|
| 229 |
+
|
| 230 |
+
If a pre-trained weight file is necessary,
|
| 231 |
+
:func:`torch.hub.load_state_dict_from_url` is used to downloaded it.
|
| 232 |
+
|
| 233 |
+
Args:
|
| 234 |
+
dl_kwargs (dictionary of keyword arguments):
|
| 235 |
+
Passed to :func:`torch.hub.load_state_dict_from_url`.
|
| 236 |
+
|
| 237 |
+
Returns:
|
| 238 |
+
Vocoder:
|
| 239 |
+
A vocoder module, which takes spectrogram Tensor and an optional
|
| 240 |
+
length Tensor, then returns resulting waveform Tensor and an optional
|
| 241 |
+
length Tensor.
|
| 242 |
+
"""
|
| 243 |
+
|
| 244 |
+
@abstractmethod
|
| 245 |
+
def get_tacotron2(self, *, dl_kwargs=None) -> Tacotron2:
|
| 246 |
+
"""Create a Tacotron2 model with pre-trained weight.
|
| 247 |
+
|
| 248 |
+
Args:
|
| 249 |
+
dl_kwargs (dictionary of keyword arguments):
|
| 250 |
+
Passed to :func:`torch.hub.load_state_dict_from_url`.
|
| 251 |
+
|
| 252 |
+
Returns:
|
| 253 |
+
Tacotron2:
|
| 254 |
+
The resulting model.
|
| 255 |
+
"""
|
lib/python3.12/site-packages/torchaudio/pipelines/_tts/utils.py
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
from torchaudio._internal import download_url_to_file, module_utils as _mod_utils
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _get_chars():
|
| 9 |
+
return (
|
| 10 |
+
"_",
|
| 11 |
+
"-",
|
| 12 |
+
"!",
|
| 13 |
+
"'",
|
| 14 |
+
"(",
|
| 15 |
+
")",
|
| 16 |
+
",",
|
| 17 |
+
".",
|
| 18 |
+
":",
|
| 19 |
+
";",
|
| 20 |
+
"?",
|
| 21 |
+
" ",
|
| 22 |
+
"a",
|
| 23 |
+
"b",
|
| 24 |
+
"c",
|
| 25 |
+
"d",
|
| 26 |
+
"e",
|
| 27 |
+
"f",
|
| 28 |
+
"g",
|
| 29 |
+
"h",
|
| 30 |
+
"i",
|
| 31 |
+
"j",
|
| 32 |
+
"k",
|
| 33 |
+
"l",
|
| 34 |
+
"m",
|
| 35 |
+
"n",
|
| 36 |
+
"o",
|
| 37 |
+
"p",
|
| 38 |
+
"q",
|
| 39 |
+
"r",
|
| 40 |
+
"s",
|
| 41 |
+
"t",
|
| 42 |
+
"u",
|
| 43 |
+
"v",
|
| 44 |
+
"w",
|
| 45 |
+
"x",
|
| 46 |
+
"y",
|
| 47 |
+
"z",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _get_phones():
|
| 52 |
+
return (
|
| 53 |
+
"_",
|
| 54 |
+
"-",
|
| 55 |
+
"!",
|
| 56 |
+
"'",
|
| 57 |
+
"(",
|
| 58 |
+
")",
|
| 59 |
+
",",
|
| 60 |
+
".",
|
| 61 |
+
":",
|
| 62 |
+
";",
|
| 63 |
+
"?",
|
| 64 |
+
" ",
|
| 65 |
+
"AA",
|
| 66 |
+
"AA0",
|
| 67 |
+
"AA1",
|
| 68 |
+
"AA2",
|
| 69 |
+
"AE",
|
| 70 |
+
"AE0",
|
| 71 |
+
"AE1",
|
| 72 |
+
"AE2",
|
| 73 |
+
"AH",
|
| 74 |
+
"AH0",
|
| 75 |
+
"AH1",
|
| 76 |
+
"AH2",
|
| 77 |
+
"AO",
|
| 78 |
+
"AO0",
|
| 79 |
+
"AO1",
|
| 80 |
+
"AO2",
|
| 81 |
+
"AW",
|
| 82 |
+
"AW0",
|
| 83 |
+
"AW1",
|
| 84 |
+
"AW2",
|
| 85 |
+
"AY",
|
| 86 |
+
"AY0",
|
| 87 |
+
"AY1",
|
| 88 |
+
"AY2",
|
| 89 |
+
"B",
|
| 90 |
+
"CH",
|
| 91 |
+
"D",
|
| 92 |
+
"DH",
|
| 93 |
+
"EH",
|
| 94 |
+
"EH0",
|
| 95 |
+
"EH1",
|
| 96 |
+
"EH2",
|
| 97 |
+
"ER",
|
| 98 |
+
"ER0",
|
| 99 |
+
"ER1",
|
| 100 |
+
"ER2",
|
| 101 |
+
"EY",
|
| 102 |
+
"EY0",
|
| 103 |
+
"EY1",
|
| 104 |
+
"EY2",
|
| 105 |
+
"F",
|
| 106 |
+
"G",
|
| 107 |
+
"HH",
|
| 108 |
+
"IH",
|
| 109 |
+
"IH0",
|
| 110 |
+
"IH1",
|
| 111 |
+
"IH2",
|
| 112 |
+
"IY",
|
| 113 |
+
"IY0",
|
| 114 |
+
"IY1",
|
| 115 |
+
"IY2",
|
| 116 |
+
"JH",
|
| 117 |
+
"K",
|
| 118 |
+
"L",
|
| 119 |
+
"M",
|
| 120 |
+
"N",
|
| 121 |
+
"NG",
|
| 122 |
+
"OW",
|
| 123 |
+
"OW0",
|
| 124 |
+
"OW1",
|
| 125 |
+
"OW2",
|
| 126 |
+
"OY",
|
| 127 |
+
"OY0",
|
| 128 |
+
"OY1",
|
| 129 |
+
"OY2",
|
| 130 |
+
"P",
|
| 131 |
+
"R",
|
| 132 |
+
"S",
|
| 133 |
+
"SH",
|
| 134 |
+
"T",
|
| 135 |
+
"TH",
|
| 136 |
+
"UH",
|
| 137 |
+
"UH0",
|
| 138 |
+
"UH1",
|
| 139 |
+
"UH2",
|
| 140 |
+
"UW",
|
| 141 |
+
"UW0",
|
| 142 |
+
"UW1",
|
| 143 |
+
"UW2",
|
| 144 |
+
"V",
|
| 145 |
+
"W",
|
| 146 |
+
"Y",
|
| 147 |
+
"Z",
|
| 148 |
+
"ZH",
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def _to_tensor(indices):
|
| 153 |
+
lengths = torch.tensor([len(i) for i in indices], dtype=torch.int32)
|
| 154 |
+
values = [torch.tensor(i) for i in indices]
|
| 155 |
+
values = torch.nn.utils.rnn.pad_sequence(values, batch_first=True)
|
| 156 |
+
return values, lengths
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _load_phonemizer(file, dl_kwargs):
|
| 160 |
+
if not _mod_utils.is_module_available("dp"):
|
| 161 |
+
raise RuntimeError("DeepPhonemizer is not installed. Please install it.")
|
| 162 |
+
|
| 163 |
+
from dp.phonemizer import Phonemizer
|
| 164 |
+
|
| 165 |
+
# By default, dp issues DEBUG level log.
|
| 166 |
+
logger = logging.getLogger("dp")
|
| 167 |
+
orig_level = logger.level
|
| 168 |
+
logger.setLevel(logging.INFO)
|
| 169 |
+
try:
|
| 170 |
+
url = f"https://public-asai-dl-models.s3.eu-central-1.amazonaws.com/DeepPhonemizer/{file}"
|
| 171 |
+
directory = os.path.join(torch.hub.get_dir(), "checkpoints")
|
| 172 |
+
os.makedirs(directory, exist_ok=True)
|
| 173 |
+
path = os.path.join(directory, file)
|
| 174 |
+
if not os.path.exists(path):
|
| 175 |
+
dl_kwargs = {} if dl_kwargs is None else dl_kwargs
|
| 176 |
+
download_url_to_file(url, path, **dl_kwargs)
|
| 177 |
+
return Phonemizer.from_checkpoint(path)
|
| 178 |
+
finally:
|
| 179 |
+
logger.setLevel(orig_level)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def _unnormalize_waveform(waveform: torch.Tensor, bits: int) -> torch.Tensor:
|
| 183 |
+
r"""Transform waveform [-1, 1] to label [0, 2 ** bits - 1]"""
|
| 184 |
+
waveform = torch.clamp(waveform, -1, 1)
|
| 185 |
+
waveform = (waveform + 1.0) * (2**bits - 1) / 2
|
| 186 |
+
return torch.clamp(waveform, 0, 2**bits - 1).int()
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def _get_taco_params(n_symbols):
|
| 190 |
+
return {
|
| 191 |
+
"mask_padding": False,
|
| 192 |
+
"n_mels": 80,
|
| 193 |
+
"n_frames_per_step": 1,
|
| 194 |
+
"symbol_embedding_dim": 512,
|
| 195 |
+
"encoder_embedding_dim": 512,
|
| 196 |
+
"encoder_n_convolution": 3,
|
| 197 |
+
"encoder_kernel_size": 5,
|
| 198 |
+
"decoder_rnn_dim": 1024,
|
| 199 |
+
"decoder_max_step": 2000,
|
| 200 |
+
"decoder_dropout": 0.1,
|
| 201 |
+
"decoder_early_stopping": True,
|
| 202 |
+
"attention_rnn_dim": 1024,
|
| 203 |
+
"attention_hidden_dim": 128,
|
| 204 |
+
"attention_location_n_filter": 32,
|
| 205 |
+
"attention_location_kernel_size": 31,
|
| 206 |
+
"attention_dropout": 0.1,
|
| 207 |
+
"prenet_dim": 256,
|
| 208 |
+
"postnet_n_convolution": 5,
|
| 209 |
+
"postnet_kernel_size": 5,
|
| 210 |
+
"postnet_embedding_dim": 512,
|
| 211 |
+
"gate_threshold": 0.5,
|
| 212 |
+
"n_symbol": n_symbols,
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def _get_wrnn_params():
|
| 217 |
+
return {
|
| 218 |
+
"upsample_scales": [5, 5, 11],
|
| 219 |
+
"n_classes": 2**8, # n_bits = 8
|
| 220 |
+
"hop_length": 275,
|
| 221 |
+
"n_res_block": 10,
|
| 222 |
+
"n_rnn": 512,
|
| 223 |
+
"n_fc": 512,
|
| 224 |
+
"kernel_size": 5,
|
| 225 |
+
"n_freq": 80,
|
| 226 |
+
"n_hidden": 128,
|
| 227 |
+
"n_output": 128,
|
| 228 |
+
}
|
lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__init__.py
ADDED
|
File without changes
|
lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (209 Bytes). View file
|
|
|
lib/python3.12/site-packages/torchaudio/pipelines/_wav2vec2/__pycache__/aligner.cpython-312.pyc
ADDED
|
Binary file (5.1 kB). View file
|
|
|