Spaces:
Paused
Paused
Upload 462 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/INSTALLER +1 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/LICENSE +25 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/METADATA +113 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/RECORD +277 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/REQUESTED +0 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/WHEEL +5 -0
- MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/top_level.txt +2 -0
- MLPY/Lib/site-packages/torchaudio/__init__.py +53 -0
- MLPY/Lib/site-packages/torchaudio/__pycache__/__init__.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/__pycache__/kaldi_io.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/__pycache__/version.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__init__.py +61 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/__init__.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/common.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/ffmpeg.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/soundfile.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/soundfile_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/sox.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/utils.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_backend/backend.py +53 -0
- MLPY/Lib/site-packages/torchaudio/_backend/common.py +52 -0
- MLPY/Lib/site-packages/torchaudio/_backend/ffmpeg.py +334 -0
- MLPY/Lib/site-packages/torchaudio/_backend/soundfile.py +54 -0
- MLPY/Lib/site-packages/torchaudio/_backend/soundfile_backend.py +457 -0
- MLPY/Lib/site-packages/torchaudio/_backend/sox.py +91 -0
- MLPY/Lib/site-packages/torchaudio/_backend/utils.py +317 -0
- MLPY/Lib/site-packages/torchaudio/_extension/__init__.py +74 -0
- MLPY/Lib/site-packages/torchaudio/_extension/__pycache__/__init__.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_extension/__pycache__/utils.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_extension/utils.py +180 -0
- MLPY/Lib/site-packages/torchaudio/_internal/__init__.py +10 -0
- MLPY/Lib/site-packages/torchaudio/_internal/__pycache__/__init__.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_internal/__pycache__/module_utils.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/_internal/module_utils.py +113 -0
- MLPY/Lib/site-packages/torchaudio/backend/__init__.py +8 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/__init__.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/_no_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/_sox_io_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/common.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/no_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/soundfile_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/__pycache__/sox_io_backend.cpython-39.pyc +0 -0
- MLPY/Lib/site-packages/torchaudio/backend/_no_backend.py +25 -0
- MLPY/Lib/site-packages/torchaudio/backend/_sox_io_backend.py +294 -0
- MLPY/Lib/site-packages/torchaudio/backend/common.py +13 -0
- MLPY/Lib/site-packages/torchaudio/backend/no_backend.py +14 -0
- MLPY/Lib/site-packages/torchaudio/backend/soundfile_backend.py +14 -0
- MLPY/Lib/site-packages/torchaudio/backend/sox_io_backend.py +14 -0
.gitattributes
CHANGED
@@ -101,3 +101,4 @@ MLPY/Lib/site-packages/torch/lib/torch_cpu.dll filter=lfs diff=lfs merge=lfs -te
|
|
101 |
MLPY/Lib/site-packages/torch/lib/torch_cpu.lib filter=lfs diff=lfs merge=lfs -text
|
102 |
MLPY/Lib/site-packages/torch/lib/torch_python.dll filter=lfs diff=lfs merge=lfs -text
|
103 |
MLPY/Lib/site-packages/torch/lib/XNNPACK.lib filter=lfs diff=lfs merge=lfs -text
|
|
|
|
101 |
MLPY/Lib/site-packages/torch/lib/torch_cpu.lib filter=lfs diff=lfs merge=lfs -text
|
102 |
MLPY/Lib/site-packages/torch/lib/torch_python.dll filter=lfs diff=lfs merge=lfs -text
|
103 |
MLPY/Lib/site-packages/torch/lib/XNNPACK.lib filter=lfs diff=lfs merge=lfs -text
|
104 |
+
MLPY/Lib/site-packages/torchaudio/lib/libtorchaudio.pyd filter=lfs diff=lfs merge=lfs -text
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/INSTALLER
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pip
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
BSD 2-Clause License
|
2 |
+
|
3 |
+
Copyright (c) 2017 Facebook Inc. (Soumith Chintala),
|
4 |
+
All rights reserved.
|
5 |
+
|
6 |
+
Redistribution and use in source and binary forms, with or without
|
7 |
+
modification, are permitted provided that the following conditions are met:
|
8 |
+
|
9 |
+
* Redistributions of source code must retain the above copyright notice, this
|
10 |
+
list of conditions and the following disclaimer.
|
11 |
+
|
12 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13 |
+
this list of conditions and the following disclaimer in the documentation
|
14 |
+
and/or other materials provided with the distribution.
|
15 |
+
|
16 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/METADATA
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Metadata-Version: 2.1
|
2 |
+
Name: torchaudio
|
3 |
+
Version: 2.3.1
|
4 |
+
Summary: An audio package for PyTorch
|
5 |
+
Home-page: https://github.com/pytorch/audio
|
6 |
+
Author: Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough, Moto Hira, Caroline Chen, Jeff Hwang, Zhaoheng Ni, Xiaohui Zhang
|
7 |
+
Author-email: [email protected]
|
8 |
+
Maintainer: Moto Hira, Caroline Chen, Jeff Hwang, Zhaoheng Ni, Xiaohui Zhang
|
9 |
+
Maintainer-email: [email protected]
|
10 |
+
Classifier: Environment :: Plugins
|
11 |
+
Classifier: Intended Audience :: Developers
|
12 |
+
Classifier: Intended Audience :: Science/Research
|
13 |
+
Classifier: License :: OSI Approved :: BSD License
|
14 |
+
Classifier: Operating System :: MacOS :: MacOS X
|
15 |
+
Classifier: Operating System :: Microsoft :: Windows
|
16 |
+
Classifier: Operating System :: POSIX
|
17 |
+
Classifier: Programming Language :: C++
|
18 |
+
Classifier: Programming Language :: Python :: 3.8
|
19 |
+
Classifier: Programming Language :: Python :: 3.9
|
20 |
+
Classifier: Programming Language :: Python :: 3.10
|
21 |
+
Classifier: Programming Language :: Python :: 3.11
|
22 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
23 |
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
24 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
25 |
+
Description-Content-Type: text/markdown
|
26 |
+
License-File: LICENSE
|
27 |
+
Requires-Dist: torch (==2.3.1)
|
28 |
+
|
29 |
+
torchaudio: an audio library for PyTorch
|
30 |
+
========================================
|
31 |
+
|
32 |
+
[![Documentation](https://img.shields.io/badge/dynamic/json.svg?label=docs&url=https%3A%2F%2Fpypi.org%2Fpypi%2Ftorchaudio%2Fjson&query=%24.info.version&colorB=brightgreen&prefix=v)](https://pytorch.org/audio/main/)
|
33 |
+
[![Anaconda Badge](https://anaconda.org/pytorch/torchaudio/badges/downloads.svg)](https://anaconda.org/pytorch/torchaudio)
|
34 |
+
[![Anaconda-Server Badge](https://anaconda.org/pytorch/torchaudio/badges/platforms.svg)](https://anaconda.org/pytorch/torchaudio)
|
35 |
+
|
36 |
+
![TorchAudio Logo](docs/source/_static/img/logo.png)
|
37 |
+
|
38 |
+
The aim of torchaudio is to apply [PyTorch](https://github.com/pytorch/pytorch) to
|
39 |
+
the audio domain. By supporting PyTorch, torchaudio follows the same philosophy
|
40 |
+
of providing strong GPU acceleration, having a focus on trainable features through
|
41 |
+
the autograd system, and having consistent style (tensor names and dimension names).
|
42 |
+
Therefore, it is primarily a machine learning library and not a general signal
|
43 |
+
processing library. The benefits of PyTorch can be seen in torchaudio through
|
44 |
+
having all the computations be through PyTorch operations which makes it easy
|
45 |
+
to use and feel like a natural extension.
|
46 |
+
|
47 |
+
- [Support audio I/O (Load files, Save files)](http://pytorch.org/audio/main/)
|
48 |
+
- Load a variety of audio formats, such as `wav`, `mp3`, `ogg`, `flac`, `opus`, `sphere`, into a torch Tensor using SoX
|
49 |
+
- [Kaldi (ark/scp)](http://pytorch.org/audio/main/kaldi_io.html)
|
50 |
+
- [Dataloaders for common audio datasets](http://pytorch.org/audio/main/datasets.html)
|
51 |
+
- Audio and speech processing functions
|
52 |
+
- [forced_align](https://pytorch.org/audio/main/generated/torchaudio.functional.forced_align.html)
|
53 |
+
- Common audio transforms
|
54 |
+
- [Spectrogram, AmplitudeToDB, MelScale, MelSpectrogram, MFCC, MuLawEncoding, MuLawDecoding, Resample](http://pytorch.org/audio/main/transforms.html)
|
55 |
+
- Compliance interfaces: Run code using PyTorch that align with other libraries
|
56 |
+
- [Kaldi: spectrogram, fbank, mfcc](https://pytorch.org/audio/main/compliance.kaldi.html)
|
57 |
+
|
58 |
+
Installation
|
59 |
+
------------
|
60 |
+
|
61 |
+
Please refer to https://pytorch.org/audio/main/installation.html for installation and build process of TorchAudio.
|
62 |
+
|
63 |
+
|
64 |
+
API Reference
|
65 |
+
-------------
|
66 |
+
|
67 |
+
API Reference is located here: http://pytorch.org/audio/main/
|
68 |
+
|
69 |
+
Contributing Guidelines
|
70 |
+
-----------------------
|
71 |
+
|
72 |
+
Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md)
|
73 |
+
|
74 |
+
Citation
|
75 |
+
--------
|
76 |
+
|
77 |
+
If you find this package useful, please cite as:
|
78 |
+
|
79 |
+
```bibtex
|
80 |
+
@article{yang2021torchaudio,
|
81 |
+
title={TorchAudio: Building Blocks for Audio and Speech Processing},
|
82 |
+
author={Yao-Yuan Yang and Moto Hira and Zhaoheng Ni and Anjali Chourdia and Artyom Astafurov and Caroline Chen and Ching-Feng Yeh and Christian Puhrsch and David Pollack and Dmitriy Genzel and Donny Greenberg and Edward Z. Yang and Jason Lian and Jay Mahadeokar and Jeff Hwang and Ji Chen and Peter Goldsborough and Prabhat Roy and Sean Narenthiran and Shinji Watanabe and Soumith Chintala and Vincent Quenneville-Bélair and Yangyang Shi},
|
83 |
+
journal={arXiv preprint arXiv:2110.15018},
|
84 |
+
year={2021}
|
85 |
+
}
|
86 |
+
```
|
87 |
+
|
88 |
+
```bibtex
|
89 |
+
@misc{hwang2023torchaudio,
|
90 |
+
title={TorchAudio 2.1: Advancing speech recognition, self-supervised learning, and audio processing components for PyTorch},
|
91 |
+
author={Jeff Hwang and Moto Hira and Caroline Chen and Xiaohui Zhang and Zhaoheng Ni and Guangzhi Sun and Pingchuan Ma and Ruizhe Huang and Vineel Pratap and Yuekai Zhang and Anurag Kumar and Chin-Yun Yu and Chuang Zhu and Chunxi Liu and Jacob Kahn and Mirco Ravanelli and Peng Sun and Shinji Watanabe and Yangyang Shi and Yumeng Tao and Robin Scheibler and Samuele Cornell and Sean Kim and Stavros Petridis},
|
92 |
+
year={2023},
|
93 |
+
eprint={2310.17864},
|
94 |
+
archivePrefix={arXiv},
|
95 |
+
primaryClass={eess.AS}
|
96 |
+
}
|
97 |
+
```
|
98 |
+
|
99 |
+
Disclaimer on Datasets
|
100 |
+
----------------------
|
101 |
+
|
102 |
+
This is a utility library that downloads and prepares public datasets. We do not host or distribute these datasets, vouch for their quality or fairness, or claim that you have license to use the dataset. It is your responsibility to determine whether you have permission to use the dataset under the dataset's license.
|
103 |
+
|
104 |
+
If you're a dataset owner and wish to update any part of it (description, citation, etc.), or do not want your dataset to be included in this library, please get in touch through a GitHub issue. Thanks for your contribution to the ML community!
|
105 |
+
|
106 |
+
Pre-trained Model License
|
107 |
+
-------------------------
|
108 |
+
|
109 |
+
The pre-trained models provided in this library may have their own licenses or terms and conditions derived from the dataset used for training. It is your responsibility to determine whether you have permission to use the models for your use case.
|
110 |
+
|
111 |
+
For instance, SquimSubjective model is released under the Creative Commons Attribution Non Commercial 4.0 International (CC-BY-NC 4.0) license. See [the link](https://zenodo.org/record/4660670#.ZBtWPOxuerN) for additional details.
|
112 |
+
|
113 |
+
Other pre-trained models that have different license are noted in documentation. Please checkout the [documentation page](https://pytorch.org/audio/main/).
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/RECORD
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torchaudio-2.3.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
2 |
+
torchaudio-2.3.1.dist-info/LICENSE,sha256=MmOOF5kxv-VR6r9nsOZ6E7SD4Wa1jdcmNjSrf4nzlvU,1363
|
3 |
+
torchaudio-2.3.1.dist-info/METADATA,sha256=bn96zltasEUWCzMa6jcqOUW2YAvCuLLFKzwGjxbjxL0,6351
|
4 |
+
torchaudio-2.3.1.dist-info/RECORD,,
|
5 |
+
torchaudio-2.3.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6 |
+
torchaudio-2.3.1.dist-info/WHEEL,sha256=fVcVlLzi8CGi_Ul8vjMdn8gER25dn5GBg9E6k9z41-Y,100
|
7 |
+
torchaudio-2.3.1.dist-info/top_level.txt,sha256=GT0MktEbHKoLnvd-6ii7_dhJVvshupOujk840BcHU4U,17
|
8 |
+
torchaudio/__init__.py,sha256=kUWnkwcKERMj7m-B4E826aGZWGa5sJs1DEpLP6LZoEs,945
|
9 |
+
torchaudio/__pycache__/__init__.cpython-39.pyc,,
|
10 |
+
torchaudio/__pycache__/kaldi_io.cpython-39.pyc,,
|
11 |
+
torchaudio/__pycache__/version.cpython-39.pyc,,
|
12 |
+
torchaudio/_backend/__init__.py,sha256=2bMTZ3tG2_5nvnqAAmvEnGBInO5a9DdUPNoyXEnX1M0,1692
|
13 |
+
torchaudio/_backend/__pycache__/__init__.cpython-39.pyc,,
|
14 |
+
torchaudio/_backend/__pycache__/backend.cpython-39.pyc,,
|
15 |
+
torchaudio/_backend/__pycache__/common.cpython-39.pyc,,
|
16 |
+
torchaudio/_backend/__pycache__/ffmpeg.cpython-39.pyc,,
|
17 |
+
torchaudio/_backend/__pycache__/soundfile.cpython-39.pyc,,
|
18 |
+
torchaudio/_backend/__pycache__/soundfile_backend.cpython-39.pyc,,
|
19 |
+
torchaudio/_backend/__pycache__/sox.cpython-39.pyc,,
|
20 |
+
torchaudio/_backend/__pycache__/utils.cpython-39.pyc,,
|
21 |
+
torchaudio/_backend/backend.py,sha256=CakqB9z_4ZtLsQTyMZbEbB0kTqpUe_gidHgObv9acyQ,1618
|
22 |
+
torchaudio/_backend/common.py,sha256=h9R29RTTW2lqOiKYByETXfXWsrTH65uHxGDKw3bWj-s,1835
|
23 |
+
torchaudio/_backend/ffmpeg.py,sha256=b6dr67sWg47uFJxIyWLXCtrdPMlgjYdWmj7n919Ph1M,11628
|
24 |
+
torchaudio/_backend/soundfile.py,sha256=Dd-K6Tg_G3ze08hImvnAsO5lpAERpmUd9oxkNsGJUno,1757
|
25 |
+
torchaudio/_backend/soundfile_backend.py,sha256=sVSEM2On6PMY7AbPqpfvE1u1Bg2_0aiSrZ4TclAFi_w,17833
|
26 |
+
torchaudio/_backend/sox.py,sha256=UGF352HA_5kXebHEdxOlvyNgruYacxDkeJy4ErggRhI,3451
|
27 |
+
torchaudio/_backend/utils.py,sha256=8HkmV_GCHZhD-XaKNQ60nGFsu7rVgr1SOhasN6v91aI,13616
|
28 |
+
torchaudio/_extension/__init__.py,sha256=s6AzXocDcuh0mtYVUCOOjZ_mCmSCno8jbZN750YI-Ps,2276
|
29 |
+
torchaudio/_extension/__pycache__/__init__.cpython-39.pyc,,
|
30 |
+
torchaudio/_extension/__pycache__/utils.cpython-39.pyc,,
|
31 |
+
torchaudio/_extension/utils.py,sha256=wFDF8B6Q22UL3zyX8swZ-JjlDgm9-VdjeraslQr2yIY,6438
|
32 |
+
torchaudio/_internal/__init__.py,sha256=80cpJfTS8977YYrU3q5p4DRAGAkqEJrmG9Lq2hEDpoo,251
|
33 |
+
torchaudio/_internal/__pycache__/__init__.cpython-39.pyc,,
|
34 |
+
torchaudio/_internal/__pycache__/module_utils.cpython-39.pyc,,
|
35 |
+
torchaudio/_internal/module_utils.py,sha256=d0Gf_DhaA-fEtxKHjWhDwYrBsH6CCk41eUi_9THhQ9k,3675
|
36 |
+
torchaudio/backend/__init__.py,sha256=ckKT_tmcmc_Z43ZTlqJ39fwUbmv-j-mAP2BWp0sU4Tg,289
|
37 |
+
torchaudio/backend/__pycache__/__init__.cpython-39.pyc,,
|
38 |
+
torchaudio/backend/__pycache__/_no_backend.cpython-39.pyc,,
|
39 |
+
torchaudio/backend/__pycache__/_sox_io_backend.cpython-39.pyc,,
|
40 |
+
torchaudio/backend/__pycache__/common.cpython-39.pyc,,
|
41 |
+
torchaudio/backend/__pycache__/no_backend.cpython-39.pyc,,
|
42 |
+
torchaudio/backend/__pycache__/soundfile_backend.cpython-39.pyc,,
|
43 |
+
torchaudio/backend/__pycache__/sox_io_backend.cpython-39.pyc,,
|
44 |
+
torchaudio/backend/_no_backend.py,sha256=CEpYJ0bZi937Z0q2JHdRVnDKd7HWlCUVR7rEVHE_xmE,782
|
45 |
+
torchaudio/backend/_sox_io_backend.py,sha256=Ut3-QaqzaJ0MvNc7NdpMTST7_mZy1xSixGbDC7418Qk,11750
|
46 |
+
torchaudio/backend/common.py,sha256=mn0l6GBwet7DvRQPURhYIHF-HrQFvEFVKM23PawfbH8,456
|
47 |
+
torchaudio/backend/no_backend.py,sha256=xc-k0kqzYOEM6dvcIwiMDEaLutKrYXXCsCXF1IVFNHM,483
|
48 |
+
torchaudio/backend/soundfile_backend.py,sha256=NFHAQcz8kwlgI7qIG1bYrbgzsjtDCkNn_Gmip6vBL6g,513
|
49 |
+
torchaudio/backend/sox_io_backend.py,sha256=_DD1_6y4eV4MsIl2Clcxnq96k_EXT0XMu5p2Z61gnEs,491
|
50 |
+
torchaudio/compliance/__init__.py,sha256=JNH_-dTQVmm55YwcVMuVvUYFWdXhGn4C__9S8IUsNoU,53
|
51 |
+
torchaudio/compliance/__pycache__/__init__.cpython-39.pyc,,
|
52 |
+
torchaudio/compliance/__pycache__/kaldi.cpython-39.pyc,,
|
53 |
+
torchaudio/compliance/kaldi.py,sha256=bS7qJgS3k8FK1RkMiNEoP3q0xhjeV_V4RHQ9jo_rqOM,37479
|
54 |
+
torchaudio/datasets/__init__.py,sha256=hdHldm3OzoQLbI0kHj8tLxqwDhzMfedq0_t1kAK7ORg,1218
|
55 |
+
torchaudio/datasets/__pycache__/__init__.cpython-39.pyc,,
|
56 |
+
torchaudio/datasets/__pycache__/cmuarctic.cpython-39.pyc,,
|
57 |
+
torchaudio/datasets/__pycache__/cmudict.cpython-39.pyc,,
|
58 |
+
torchaudio/datasets/__pycache__/commonvoice.cpython-39.pyc,,
|
59 |
+
torchaudio/datasets/__pycache__/dr_vctk.cpython-39.pyc,,
|
60 |
+
torchaudio/datasets/__pycache__/fluentcommands.cpython-39.pyc,,
|
61 |
+
torchaudio/datasets/__pycache__/gtzan.cpython-39.pyc,,
|
62 |
+
torchaudio/datasets/__pycache__/iemocap.cpython-39.pyc,,
|
63 |
+
torchaudio/datasets/__pycache__/librilight_limited.cpython-39.pyc,,
|
64 |
+
torchaudio/datasets/__pycache__/librimix.cpython-39.pyc,,
|
65 |
+
torchaudio/datasets/__pycache__/librispeech.cpython-39.pyc,,
|
66 |
+
torchaudio/datasets/__pycache__/librispeech_biasing.cpython-39.pyc,,
|
67 |
+
torchaudio/datasets/__pycache__/libritts.cpython-39.pyc,,
|
68 |
+
torchaudio/datasets/__pycache__/ljspeech.cpython-39.pyc,,
|
69 |
+
torchaudio/datasets/__pycache__/musdb_hq.cpython-39.pyc,,
|
70 |
+
torchaudio/datasets/__pycache__/quesst14.cpython-39.pyc,,
|
71 |
+
torchaudio/datasets/__pycache__/snips.cpython-39.pyc,,
|
72 |
+
torchaudio/datasets/__pycache__/speechcommands.cpython-39.pyc,,
|
73 |
+
torchaudio/datasets/__pycache__/tedlium.cpython-39.pyc,,
|
74 |
+
torchaudio/datasets/__pycache__/utils.cpython-39.pyc,,
|
75 |
+
torchaudio/datasets/__pycache__/vctk.cpython-39.pyc,,
|
76 |
+
torchaudio/datasets/__pycache__/voxceleb1.cpython-39.pyc,,
|
77 |
+
torchaudio/datasets/__pycache__/yesno.cpython-39.pyc,,
|
78 |
+
torchaudio/datasets/cmuarctic.py,sha256=xEHBtO8oh5ub8VbLa1qcL-meFhYeg4EQpMUdiGaelGA,7254
|
79 |
+
torchaudio/datasets/cmudict.py,sha256=_9vTz7_8BFVrcHeA61_-h2XLOl6IsdWCptkMWziOW7U,6176
|
80 |
+
torchaudio/datasets/commonvoice.py,sha256=OcFn-nG4YfBIz0YIpH91xH9rFka8yFJmrxy4vFZkC4I,2849
|
81 |
+
torchaudio/datasets/dr_vctk.py,sha256=Ayf85prDNr1LcWQ4bysVWdRVPry2JALjv6Mtq-6iBpY,4498
|
82 |
+
torchaudio/datasets/fluentcommands.py,sha256=KnmH1Y28k5PhqQX6eV-75MqwTRxiHSUUcvAsa-K954s,3353
|
83 |
+
torchaudio/datasets/gtzan.py,sha256=kt25Ly9qDGuiiVXgsXhS05tGi6laRhRko81-BQ4sZ-w,25475
|
84 |
+
torchaudio/datasets/iemocap.py,sha256=ZMMG_FpcWcMHEbhuRYRQaUWi_DoegjxCrnVyCg5EEVE,5077
|
85 |
+
torchaudio/datasets/librilight_limited.py,sha256=iwZBlSKVLrXzhZvaqjuVRGO6czxX4fpdzd8wWe5feWQ,4290
|
86 |
+
torchaudio/datasets/librimix.py,sha256=AncE671AOl04dRPsajNZW-ZxxI_PwA2sjBftdBg4Q-k,5249
|
87 |
+
torchaudio/datasets/librispeech.py,sha256=ys769I0UzG07UEmyZ_KDwATh4yc08hFUuCayK8tYIGg,6482
|
88 |
+
torchaudio/datasets/librispeech_biasing.py,sha256=KEGplRU_wpgb0VqrT-t42kvtC7lg4uMssZcosVvvPhg,7147
|
89 |
+
torchaudio/datasets/libritts.py,sha256=91Ep2Mq3OySre25GniXBLmRzTwEPiKmMaqXnzirn0xY,6038
|
90 |
+
torchaudio/datasets/ljspeech.py,sha256=l09BSBQH76I-LhYkIRF0u18tTi-4yysaF4gj2GSZaxw,3601
|
91 |
+
torchaudio/datasets/musdb_hq.py,sha256=FVlKsGEBHiT50y9GLswnt2QFph2PjiI6yCy1MxiG6f8,5214
|
92 |
+
torchaudio/datasets/quesst14.py,sha256=3y6H3T3g78jkDqca8jORQBOViZhH1RhlsfuY8HJ2OcU,4591
|
93 |
+
torchaudio/datasets/snips.py,sha256=mwVc5KsbMlPQJ87eyYgjnQ5S4EFXoQvm13dO0rXpJuE,5165
|
94 |
+
torchaudio/datasets/speechcommands.py,sha256=_wmrKSiEe0COO7uk0JVXypBmNxu0urnceHuFQ6zMOk0,7664
|
95 |
+
torchaudio/datasets/tedlium.py,sha256=UQZUaeUqmFntZWcH9HXOpGeW6tsCcG81bPjX2_CWxbg,8916
|
96 |
+
torchaudio/datasets/utils.py,sha256=m-sBYgQb0JxgGVfsVpekKFDI_7PGXCTma6N2ymfJl0g,1743
|
97 |
+
torchaudio/datasets/vctk.py,sha256=vN_VzxTLyHW11I_rzfzMVA3h5JW917FaU3NCnR-zcL0,5842
|
98 |
+
torchaudio/datasets/voxceleb1.py,sha256=JlYkbyYOAFUFhGLULe3lgucANWf_G7qGqw47YjiX2IM,12034
|
99 |
+
torchaudio/datasets/yesno.py,sha256=B3hRNUazvB8V8SwOUlQzliB9vI9gMkl9SEl-dZ4PEaw,3115
|
100 |
+
torchaudio/functional/__init__.py,sha256=NwlPoWjNravX4itCZy-dzN-BkCFdDHFRwvPle8JjBRo,2484
|
101 |
+
torchaudio/functional/__pycache__/__init__.cpython-39.pyc,,
|
102 |
+
torchaudio/functional/__pycache__/_alignment.cpython-39.pyc,,
|
103 |
+
torchaudio/functional/__pycache__/filtering.cpython-39.pyc,,
|
104 |
+
torchaudio/functional/__pycache__/functional.cpython-39.pyc,,
|
105 |
+
torchaudio/functional/_alignment.py,sha256=46GhuEYUqI1gE-2UKSu9BIQF1QpZ5yunUS8JZGZJuss,4823
|
106 |
+
torchaudio/functional/filtering.py,sha256=L3PaGnp7QKXwL4JECNSAhAVP92rrR8BGfdXoybSrHFU,63114
|
107 |
+
torchaudio/functional/functional.py,sha256=qjdU3kILy69-jQL3lQ2EO1y_dpLDif_jAp99hBRJnPo,98541
|
108 |
+
torchaudio/io/__init__.py,sha256=5U3MlGVGw5vPTZqCZ-7N25oVfwssA6KUtluj-9rNRMM,310
|
109 |
+
torchaudio/io/__pycache__/__init__.cpython-39.pyc,,
|
110 |
+
torchaudio/io/__pycache__/_effector.cpython-39.pyc,,
|
111 |
+
torchaudio/io/__pycache__/_playback.cpython-39.pyc,,
|
112 |
+
torchaudio/io/_effector.py,sha256=5Kh7br-ZuLzmoRSVXk5JNQ8NkwcGUiY_mrt7d_1W1eg,12217
|
113 |
+
torchaudio/io/_playback.py,sha256=UpPb-m35XUlYL2lybQGXAJAvfmUPT_Kqx4jpYArIAz0,2393
|
114 |
+
torchaudio/kaldi_io.py,sha256=acwysr6fASV9IcOTF0AbVPCo_VQTu1M2AOn1SXm3GPE,5217
|
115 |
+
torchaudio/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
116 |
+
torchaudio/lib/__pycache__/__init__.cpython-39.pyc,,
|
117 |
+
torchaudio/lib/_torchaudio.pyd,sha256=WV5FJJ0zngA8tfjY5dGw8UE-ul0KATMLjORqNkSLpak,747520
|
118 |
+
torchaudio/lib/libtorchaudio.pyd,sha256=ls9OvefkxpldUFhB-ngN1c7IAI8tIZwy6Q8jN8cLY00,1052672
|
119 |
+
torchaudio/models/__init__.py,sha256=Gi3UQvxjwTLW9wfKlF42O3Vup70d0bk2x-rZS89ASwI,2080
|
120 |
+
torchaudio/models/__pycache__/__init__.cpython-39.pyc,,
|
121 |
+
torchaudio/models/__pycache__/_hdemucs.cpython-39.pyc,,
|
122 |
+
torchaudio/models/__pycache__/conformer.cpython-39.pyc,,
|
123 |
+
torchaudio/models/__pycache__/conv_tasnet.cpython-39.pyc,,
|
124 |
+
torchaudio/models/__pycache__/deepspeech.cpython-39.pyc,,
|
125 |
+
torchaudio/models/__pycache__/emformer.cpython-39.pyc,,
|
126 |
+
torchaudio/models/__pycache__/rnnt.cpython-39.pyc,,
|
127 |
+
torchaudio/models/__pycache__/rnnt_decoder.cpython-39.pyc,,
|
128 |
+
torchaudio/models/__pycache__/tacotron2.cpython-39.pyc,,
|
129 |
+
torchaudio/models/__pycache__/wav2letter.cpython-39.pyc,,
|
130 |
+
torchaudio/models/__pycache__/wavernn.cpython-39.pyc,,
|
131 |
+
torchaudio/models/_hdemucs.py,sha256=ipAj7965PO_WEZqQwW1om9gQj90UhQOeU6HU3Lpvzwo,39250
|
132 |
+
torchaudio/models/conformer.py,sha256=gVrOYeJkPlVaX-4eZpVzNUe_r3k7g1Y6NaaQ8JZP-r4,10361
|
133 |
+
torchaudio/models/conv_tasnet.py,sha256=D7Y10sOzLe03gygfN1J5R73SIHkIGVQOkqKQ6Ni3o_s,12870
|
134 |
+
torchaudio/models/decoder/__init__.py,sha256=WMh4udN8CGF-SvgN6JBXSNMjhZqm1et7FyMrsk6V6RM,1252
|
135 |
+
torchaudio/models/decoder/__pycache__/__init__.cpython-39.pyc,,
|
136 |
+
torchaudio/models/decoder/__pycache__/_ctc_decoder.cpython-39.pyc,,
|
137 |
+
torchaudio/models/decoder/__pycache__/_cuda_ctc_decoder.cpython-39.pyc,,
|
138 |
+
torchaudio/models/decoder/_ctc_decoder.py,sha256=woyUaDCuaMQqPTQ7uLuc99lxMAOsJj5AxWwS9hf6JNY,20650
|
139 |
+
torchaudio/models/decoder/_cuda_ctc_decoder.py,sha256=BZCjAdZ50umWW171nJYHy24YZ5CxM8a2JfMIeO4S3BM,7373
|
140 |
+
torchaudio/models/deepspeech.py,sha256=nVYc2xwWpFO6gu5CR0mbqLiAzJn8lAfHcdcP92i22mo,2830
|
141 |
+
torchaudio/models/emformer.py,sha256=WbaeZcrPFOOLn4igqweE0AfuF_SQZpqg7XPGEhl7C8c,38650
|
142 |
+
torchaudio/models/rnnt.py,sha256=PNJpZd3vH6wRq8TEf4UlPtVHbte9wOJ-bRMEug6gp08,36357
|
143 |
+
torchaudio/models/rnnt_decoder.py,sha256=CBBMZhhq5Bgax0_3p3SZD-Os3S1LFHB91oTgVED4bmY,13178
|
144 |
+
torchaudio/models/squim/__init__.py,sha256=eQox8kPviOthKulpzZvPK0a66NHW7MzYE4aOF7va_kU,357
|
145 |
+
torchaudio/models/squim/__pycache__/__init__.cpython-39.pyc,,
|
146 |
+
torchaudio/models/squim/__pycache__/objective.cpython-39.pyc,,
|
147 |
+
torchaudio/models/squim/__pycache__/subjective.cpython-39.pyc,,
|
148 |
+
torchaudio/models/squim/objective.py,sha256=0Dsio0cQ_NBHg7t0YFbBamyiWPpocfaErddnBttu8b0,12615
|
149 |
+
torchaudio/models/squim/subjective.py,sha256=1_gK9O3nvrjiikpP46IdsMzKduSTt91kKklA69wQqiw,5947
|
150 |
+
torchaudio/models/tacotron2.py,sha256=mZ5lLSa75oqc0hgkc3sIm5_gK-knhtgX3dmg9-oLQao,46960
|
151 |
+
torchaudio/models/wav2letter.py,sha256=oetxpH5RG0TadYB75IOmYOrnraaPvSlcSNpRZb2FE_A,3350
|
152 |
+
torchaudio/models/wav2vec2/__init__.py,sha256=j5FdQFfuIpdIKYwoMLop4Ba70GGoS-lK61tU-oNG5wg,972
|
153 |
+
torchaudio/models/wav2vec2/__pycache__/__init__.cpython-39.pyc,,
|
154 |
+
torchaudio/models/wav2vec2/__pycache__/components.cpython-39.pyc,,
|
155 |
+
torchaudio/models/wav2vec2/__pycache__/model.cpython-39.pyc,,
|
156 |
+
torchaudio/models/wav2vec2/__pycache__/wavlm_attention.cpython-39.pyc,,
|
157 |
+
torchaudio/models/wav2vec2/components.py,sha256=EzmuGc5qHVPrHCGqYVHTvdjqP2gCrBfnHSoTK9GsZ1w,48244
|
158 |
+
torchaudio/models/wav2vec2/model.py,sha256=kP6QKsF1PjleyUMhaPjydi0pCRy4GGUArRWBzfDJmdE,61671
|
159 |
+
torchaudio/models/wav2vec2/utils/__init__.py,sha256=1eowaOEKRbp7JajFNv_r47REJqnMmXidukS7Mrwp_5Q,188
|
160 |
+
torchaudio/models/wav2vec2/utils/__pycache__/__init__.cpython-39.pyc,,
|
161 |
+
torchaudio/models/wav2vec2/utils/__pycache__/import_fairseq.cpython-39.pyc,,
|
162 |
+
torchaudio/models/wav2vec2/utils/__pycache__/import_huggingface.cpython-39.pyc,,
|
163 |
+
torchaudio/models/wav2vec2/utils/import_fairseq.py,sha256=so7T-otDNCsTUtzJRUFFGWyd0caWl3RY_UbFMxJ4DJE,9411
|
164 |
+
torchaudio/models/wav2vec2/utils/import_huggingface.py,sha256=NMK6YrAIDfOw8j1tV-3XTwx_mwbJHvg8ldTrAWRztIM,6080
|
165 |
+
torchaudio/models/wav2vec2/wavlm_attention.py,sha256=iYde9grsb_RaEs87FI5ykyN3z0Ix1plqpsMNvakAiWM,11058
|
166 |
+
torchaudio/models/wavernn.py,sha256=LRgL36jA6WzI1PAzBY6P52oCMGSTOraXB8fEgkwpSxw,15855
|
167 |
+
torchaudio/pipelines/__init__.py,sha256=oMwOu-1T_ugJmhdaoI5NrCDrUAGrpDOlJQO8h-bLAW4,2847
|
168 |
+
torchaudio/pipelines/__pycache__/__init__.cpython-39.pyc,,
|
169 |
+
torchaudio/pipelines/__pycache__/_source_separation_pipeline.cpython-39.pyc,,
|
170 |
+
torchaudio/pipelines/__pycache__/_squim_pipeline.cpython-39.pyc,,
|
171 |
+
torchaudio/pipelines/__pycache__/rnnt_pipeline.cpython-39.pyc,,
|
172 |
+
torchaudio/pipelines/_source_separation_pipeline.py,sha256=WAjiWSlk73VS985GpKweDAfk2aKwQWI6jnGNwYHiRi8,4333
|
173 |
+
torchaudio/pipelines/_squim_pipeline.py,sha256=ChaNVSQwwT8ge6XEDJCppu2W5Cz7Ng1Y9PkHhPlVwRg,7346
|
174 |
+
torchaudio/pipelines/_tts/__init__.py,sha256=WKc5c06b_M9MvEohJZghJJWAL7vXvfwRIkdy85UCh04,442
|
175 |
+
torchaudio/pipelines/_tts/__pycache__/__init__.cpython-39.pyc,,
|
176 |
+
torchaudio/pipelines/_tts/__pycache__/impl.cpython-39.pyc,,
|
177 |
+
torchaudio/pipelines/_tts/__pycache__/interface.cpython-39.pyc,,
|
178 |
+
torchaudio/pipelines/_tts/__pycache__/utils.cpython-39.pyc,,
|
179 |
+
torchaudio/pipelines/_tts/impl.py,sha256=wwrTyTEEkew22AnzB_ZklapGaAstJSUBawhA7bOcGXM,15759
|
180 |
+
torchaudio/pipelines/_tts/interface.py,sha256=y1mU0446Vy2hHpCwMqRZt1UI4ZXl-C4tJp92EylwHh0,10479
|
181 |
+
torchaudio/pipelines/_tts/utils.py,sha256=ZqqD-TXI6zkKvYtdAHlZikKlpEO00otvOKJTTjXFOGI,4844
|
182 |
+
torchaudio/pipelines/_wav2vec2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
183 |
+
torchaudio/pipelines/_wav2vec2/__pycache__/__init__.cpython-39.pyc,,
|
184 |
+
torchaudio/pipelines/_wav2vec2/__pycache__/aligner.cpython-39.pyc,,
|
185 |
+
torchaudio/pipelines/_wav2vec2/__pycache__/impl.cpython-39.pyc,,
|
186 |
+
torchaudio/pipelines/_wav2vec2/__pycache__/utils.cpython-39.pyc,,
|
187 |
+
torchaudio/pipelines/_wav2vec2/aligner.py,sha256=HOcthFgup97QMx9ZXCmkv6jdw_zxdRT-e_SilXEujNU,2796
|
188 |
+
torchaudio/pipelines/_wav2vec2/impl.py,sha256=I6htNo4Wt5LPxX9Z8rmxarFE8BZOZBUFIU9T9k1k2Po,67260
|
189 |
+
torchaudio/pipelines/_wav2vec2/utils.py,sha256=CVawfXmVGWY8mj-_6r4KO907BpF67WAVWHEHhycFIaM,7317
|
190 |
+
torchaudio/pipelines/rnnt_pipeline.py,sha256=S0DLMPbt-lqNBWOcjG5KP2IfU1X_oTv95CVmSjxYJ2g,14129
|
191 |
+
torchaudio/prototype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
192 |
+
torchaudio/prototype/__pycache__/__init__.cpython-39.pyc,,
|
193 |
+
torchaudio/prototype/datasets/__init__.py,sha256=l2k9V6ujGOiiPUXtJqMT0sao0zIUqKOg-243PAVs7NM,51
|
194 |
+
torchaudio/prototype/datasets/__pycache__/__init__.cpython-39.pyc,,
|
195 |
+
torchaudio/prototype/datasets/__pycache__/musan.cpython-39.pyc,,
|
196 |
+
torchaudio/prototype/datasets/musan.py,sha256=eNwoPahmHFqdllmFY10D5L6ko6ZjHQI9ZdvJJ8b6vDU,2163
|
197 |
+
torchaudio/prototype/functional/__init__.py,sha256=C5uPqrnwc_VJ9ajJpudsBAmxt6-RKrHirIJa3RHLlfs,588
|
198 |
+
torchaudio/prototype/functional/__pycache__/__init__.cpython-39.pyc,,
|
199 |
+
torchaudio/prototype/functional/__pycache__/_dsp.cpython-39.pyc,,
|
200 |
+
torchaudio/prototype/functional/__pycache__/_rir.cpython-39.pyc,,
|
201 |
+
torchaudio/prototype/functional/__pycache__/functional.cpython-39.pyc,,
|
202 |
+
torchaudio/prototype/functional/_dsp.py,sha256=8mjlYBWIcqDidflvvZYtUI1Icx5hEBkyQE4XErDcHKw,17071
|
203 |
+
torchaudio/prototype/functional/_rir.py,sha256=56To55TZ9J8zTXmGEb3N14df6ADpuXAWfdfxRCe8OEA,17634
|
204 |
+
torchaudio/prototype/functional/functional.py,sha256=1alp81YX8x9DHBrIHz5RgxYrW-DEvPI59Io9p19kb64,6654
|
205 |
+
torchaudio/prototype/models/__init__.py,sha256=Yuebowh-ukX2wxlU-rGc00BVjgChr_8Wf43wpTXTLus,1290
|
206 |
+
torchaudio/prototype/models/__pycache__/__init__.cpython-39.pyc,,
|
207 |
+
torchaudio/prototype/models/__pycache__/_conformer_wav2vec2.cpython-39.pyc,,
|
208 |
+
torchaudio/prototype/models/__pycache__/_emformer_hubert.cpython-39.pyc,,
|
209 |
+
torchaudio/prototype/models/__pycache__/conv_emformer.cpython-39.pyc,,
|
210 |
+
torchaudio/prototype/models/__pycache__/hifi_gan.cpython-39.pyc,,
|
211 |
+
torchaudio/prototype/models/__pycache__/rnnt.cpython-39.pyc,,
|
212 |
+
torchaudio/prototype/models/__pycache__/rnnt_decoder.cpython-39.pyc,,
|
213 |
+
torchaudio/prototype/models/_conformer_wav2vec2.py,sha256=9Je5xp87iTzD86xUQ3h4cs0XXQYp-NLAC-tHgdiljjo,30316
|
214 |
+
torchaudio/prototype/models/_emformer_hubert.py,sha256=Uz_hKOOzK8ul5rpBx__15_oy_pklocl8SvRgmjTg7hI,13831
|
215 |
+
torchaudio/prototype/models/conv_emformer.py,sha256=txtyonaqdXG6fli91WN1mkAc6SFFzUZ3fFcY713P5VM,23601
|
216 |
+
torchaudio/prototype/models/hifi_gan.py,sha256=X8mN04yQpzbOKxKmE98nFimltOOKp4FmtT2Ipxc4N3k,12816
|
217 |
+
torchaudio/prototype/models/rnnt.py,sha256=3-O5pYW35ffEG8KwCVDQfhGp-Kj0OsP4wjzdTkdQEzo,31570
|
218 |
+
torchaudio/prototype/models/rnnt_decoder.py,sha256=CO8yo1OsIi0EQSn3GRTysPoUzQN-aiNWyrrv_86rzc4,16134
|
219 |
+
torchaudio/prototype/pipelines/__init__.py,sha256=6x8q20JhZrPYx-GtJpLzeqetS0U6xBt70Qn6ctGpuUE,394
|
220 |
+
torchaudio/prototype/pipelines/__pycache__/__init__.cpython-39.pyc,,
|
221 |
+
torchaudio/prototype/pipelines/__pycache__/hifigan_pipeline.cpython-39.pyc,,
|
222 |
+
torchaudio/prototype/pipelines/__pycache__/rnnt_pipeline.cpython-39.pyc,,
|
223 |
+
torchaudio/prototype/pipelines/_vggish/__init__.py,sha256=pkGI6k0g21XZYg6H80RO6EavTOFBNUyQkFOanr8cwtY,92
|
224 |
+
torchaudio/prototype/pipelines/_vggish/__pycache__/__init__.cpython-39.pyc,,
|
225 |
+
torchaudio/prototype/pipelines/_vggish/__pycache__/_vggish_impl.cpython-39.pyc,,
|
226 |
+
torchaudio/prototype/pipelines/_vggish/__pycache__/_vggish_pipeline.cpython-39.pyc,,
|
227 |
+
torchaudio/prototype/pipelines/_vggish/_vggish_impl.py,sha256=2elMGpd6-RCFLBS4WkEQSErGWVNK6iFTNMz95PpTIZ4,8730
|
228 |
+
torchaudio/prototype/pipelines/_vggish/_vggish_pipeline.py,sha256=Gssicwkm7Wffnk1xUUoFPSUm9_5Na0J3MZAS5OdYfGo,2795
|
229 |
+
torchaudio/prototype/pipelines/hifigan_pipeline.py,sha256=-HcU3w5AcCEcjVeXpIddVLJmeu52psCO4oTIOgw50WA,9882
|
230 |
+
torchaudio/prototype/pipelines/rnnt_pipeline.py,sha256=6zeezoHIPo-9Sc0B19cFoJrQMybmDP1MDoUZzMFheOo,2242
|
231 |
+
torchaudio/prototype/transforms/__init__.py,sha256=a-LNmupvUQvpo3CrTvqXudgY8G6cRGI1zy6j9oWST_o,234
|
232 |
+
torchaudio/prototype/transforms/__pycache__/__init__.cpython-39.pyc,,
|
233 |
+
torchaudio/prototype/transforms/__pycache__/_transforms.cpython-39.pyc,,
|
234 |
+
torchaudio/prototype/transforms/_transforms.py,sha256=DSktWkL7elGrNrNWCzZ0kaB7DNZmpX0gu_8kTJzXkf8,19600
|
235 |
+
torchaudio/sox_effects/__init__.py,sha256=NVN6rAkHxizmOsZgLnxjMX5qXcPkABzLE-hvTMaSbEw,272
|
236 |
+
torchaudio/sox_effects/__pycache__/__init__.cpython-39.pyc,,
|
237 |
+
torchaudio/sox_effects/__pycache__/sox_effects.cpython-39.pyc,,
|
238 |
+
torchaudio/sox_effects/sox_effects.py,sha256=1K7Ngy5E1i1keSMiX0GJZbVh6n8ONH7TCb_606vqBxg,11253
|
239 |
+
torchaudio/transforms/__init__.py,sha256=GYkPl29GcVu_QzUfnlw1QnfNsqiqgjtn1ZmfhAAMACo,1345
|
240 |
+
torchaudio/transforms/__pycache__/__init__.cpython-39.pyc,,
|
241 |
+
torchaudio/transforms/__pycache__/_multi_channel.cpython-39.pyc,,
|
242 |
+
torchaudio/transforms/__pycache__/_transforms.cpython-39.pyc,,
|
243 |
+
torchaudio/transforms/_multi_channel.py,sha256=Musw7dTu25HNjKeIcKHUDuqBmj_GC2e3TaakqJcffW8,22688
|
244 |
+
torchaudio/transforms/_transforms.py,sha256=YFbbZ8nV1fBR0EGiNS3GOtFM-rLkyDUpXdPh8zNab40,89009
|
245 |
+
torchaudio/utils/__init__.py,sha256=h4Jvrb4vzdxzgJqgzA-TOUqLSZ2mRVALERR8am7BlvQ,185
|
246 |
+
torchaudio/utils/__pycache__/__init__.cpython-39.pyc,,
|
247 |
+
torchaudio/utils/__pycache__/download.cpython-39.pyc,,
|
248 |
+
torchaudio/utils/__pycache__/ffmpeg_utils.cpython-39.pyc,,
|
249 |
+
torchaudio/utils/__pycache__/sox_utils.cpython-39.pyc,,
|
250 |
+
torchaudio/utils/download.py,sha256=QlO5md3u0bUBFTWjZpSBMaMeeqgZKm9LmwzdB5Ip7_c,2971
|
251 |
+
torchaudio/utils/ffmpeg_utils.py,sha256=1r5cdbhz9ZCY5jW-5_gQ5G360a2fEwd--GBFMq_TxVk,330
|
252 |
+
torchaudio/utils/sox_utils.py,sha256=Wpu9cEL3EcsovNnWKWIcosRSA_LmP1XqbZ7_9ti5imI,2520
|
253 |
+
torchaudio/version.py,sha256=sx7VDGP3v5EEWJRaR1j4udJclNQC7ql5ZZM_VGZ6skU,85
|
254 |
+
torio/__init__.py,sha256=6Rz28GL44aSOszXJewvjdcm8Fp47TgphNMPtsIBd2aE,119
|
255 |
+
torio/__pycache__/__init__.cpython-39.pyc,,
|
256 |
+
torio/_extension/__init__.py,sha256=9GnFiLWPCViTbUUNio9At1M0ALGqKtZ9lFOuPUn1Sc8,326
|
257 |
+
torio/_extension/__pycache__/__init__.cpython-39.pyc,,
|
258 |
+
torio/_extension/__pycache__/utils.cpython-39.pyc,,
|
259 |
+
torio/_extension/utils.py,sha256=ppIGBFk868z7QbfSjawHUkSO3yZ7ML2jHFgE-j6GymI,5051
|
260 |
+
torio/io/__init__.py,sha256=GSt-4DRzgiuVmNN3WwjDAMACztJidmEP5ghVOlW6OQI,235
|
261 |
+
torio/io/__pycache__/__init__.cpython-39.pyc,,
|
262 |
+
torio/io/__pycache__/_streaming_media_decoder.cpython-39.pyc,,
|
263 |
+
torio/io/__pycache__/_streaming_media_encoder.cpython-39.pyc,,
|
264 |
+
torio/io/_streaming_media_decoder.py,sha256=dx0K8PD2PZY7yRY1G_As-_8-LyQDLdYfRZPW1kmrJg0,35354
|
265 |
+
torio/io/_streaming_media_encoder.py,sha256=C4zIasotf7GlkQqtRK3vMCt2aN6FkG6NK2KUw0ZdHHo,20224
|
266 |
+
torio/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
267 |
+
torio/lib/__pycache__/__init__.cpython-39.pyc,,
|
268 |
+
torio/lib/_torio_ffmpeg4.pyd,sha256=FEzc9-479g0lidzNahehJyGK44pMmbKrJVGenEZEgJA,1710080
|
269 |
+
torio/lib/_torio_ffmpeg5.pyd,sha256=yKkS3AaRtlB1sg673VF5RrUtpJYA-0fM0x_n1qLqRkw,1710080
|
270 |
+
torio/lib/_torio_ffmpeg6.pyd,sha256=pU2aQrr2SfXXWYYvSZ48OGO2NOK0TZV6MfrjkJLwM4c,1710080
|
271 |
+
torio/lib/libtorio_ffmpeg4.pyd,sha256=2D0wyPqd2ZIVxEqmNd2AAYTmL5vKOz3qs9aKO4FF8pU,964096
|
272 |
+
torio/lib/libtorio_ffmpeg5.pyd,sha256=F3AcMUfSITxcaWFnJNqONIDWh1YBrsK9kiL1_sBdFsQ,964096
|
273 |
+
torio/lib/libtorio_ffmpeg6.pyd,sha256=-P_lsD_grPs8354Qk4Iqo0BI8KEqR44lzrspy1_FfZg,964096
|
274 |
+
torio/utils/__init__.py,sha256=uQV58SlyikUr6yF4HITASCvuX-_fnzbeDxFRzFucQE4,60
|
275 |
+
torio/utils/__pycache__/__init__.cpython-39.pyc,,
|
276 |
+
torio/utils/__pycache__/ffmpeg_utils.cpython-39.pyc,,
|
277 |
+
torio/utils/ffmpeg_utils.py,sha256=2-7XS7CEZB0-M9-Ls5Tki4v7aXGJiVg7WouAUZjt3XI,8273
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/REQUESTED
ADDED
File without changes
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/WHEEL
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Wheel-Version: 1.0
|
2 |
+
Generator: bdist_wheel (0.37.1)
|
3 |
+
Root-Is-Purelib: false
|
4 |
+
Tag: cp39-cp39-win_amd64
|
5 |
+
|
MLPY/Lib/site-packages/torchaudio-2.3.1.dist-info/top_level.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
torchaudio
|
2 |
+
torio
|
MLPY/Lib/site-packages/torchaudio/__init__.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Initialize extension and backend first
|
2 |
+
from . import _extension # noqa # usort: skip
|
3 |
+
from ._backend import ( # noqa # usort: skip
|
4 |
+
AudioMetaData,
|
5 |
+
get_audio_backend,
|
6 |
+
info,
|
7 |
+
list_audio_backends,
|
8 |
+
load,
|
9 |
+
save,
|
10 |
+
set_audio_backend,
|
11 |
+
)
|
12 |
+
|
13 |
+
from . import ( # noqa: F401
|
14 |
+
compliance,
|
15 |
+
datasets,
|
16 |
+
functional,
|
17 |
+
io,
|
18 |
+
kaldi_io,
|
19 |
+
models,
|
20 |
+
pipelines,
|
21 |
+
sox_effects,
|
22 |
+
transforms,
|
23 |
+
utils,
|
24 |
+
)
|
25 |
+
|
26 |
+
# For BC
|
27 |
+
from . import backend # noqa # usort: skip
|
28 |
+
|
29 |
+
try:
|
30 |
+
from .version import __version__, git_version # noqa: F401
|
31 |
+
except ImportError:
|
32 |
+
pass
|
33 |
+
|
34 |
+
|
35 |
+
__all__ = [
|
36 |
+
"AudioMetaData",
|
37 |
+
"load",
|
38 |
+
"info",
|
39 |
+
"save",
|
40 |
+
"io",
|
41 |
+
"compliance",
|
42 |
+
"datasets",
|
43 |
+
"functional",
|
44 |
+
"models",
|
45 |
+
"pipelines",
|
46 |
+
"kaldi_io",
|
47 |
+
"utils",
|
48 |
+
"sox_effects",
|
49 |
+
"transforms",
|
50 |
+
"list_audio_backends",
|
51 |
+
"get_audio_backend",
|
52 |
+
"set_audio_backend",
|
53 |
+
]
|
MLPY/Lib/site-packages/torchaudio/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (804 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/__pycache__/kaldi_io.cpython-39.pyc
ADDED
Binary file (4.53 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/__pycache__/version.cpython-39.pyc
ADDED
Binary file (232 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__init__.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Optional
|
2 |
+
|
3 |
+
from torchaudio._internal.module_utils import deprecated
|
4 |
+
|
5 |
+
from . import utils
|
6 |
+
from .common import AudioMetaData
|
7 |
+
|
8 |
+
__all__ = [
|
9 |
+
"AudioMetaData",
|
10 |
+
"load",
|
11 |
+
"info",
|
12 |
+
"save",
|
13 |
+
"list_audio_backends",
|
14 |
+
"get_audio_backend",
|
15 |
+
"set_audio_backend",
|
16 |
+
]
|
17 |
+
|
18 |
+
|
19 |
+
info = utils.get_info_func()
|
20 |
+
load = utils.get_load_func()
|
21 |
+
save = utils.get_save_func()
|
22 |
+
|
23 |
+
|
24 |
+
def list_audio_backends() -> List[str]:
|
25 |
+
"""List available backends
|
26 |
+
|
27 |
+
Returns:
|
28 |
+
list of str: The list of available backends.
|
29 |
+
|
30 |
+
The possible values are; ``"ffmpeg"``, ``"sox"`` and ``"soundfile"``.
|
31 |
+
"""
|
32 |
+
|
33 |
+
return list(utils.get_available_backends().keys())
|
34 |
+
|
35 |
+
|
36 |
+
# Temporary until global backend is removed
|
37 |
+
@deprecated("With dispatcher enabled, this function is no-op. You can remove the function call.")
|
38 |
+
def get_audio_backend() -> Optional[str]:
|
39 |
+
"""Get the name of the current global backend
|
40 |
+
|
41 |
+
Returns:
|
42 |
+
str or None:
|
43 |
+
If dispatcher mode is enabled, returns ``None`` otherwise,
|
44 |
+
the name of current backend or ``None`` (no backend is set).
|
45 |
+
"""
|
46 |
+
return None
|
47 |
+
|
48 |
+
|
49 |
+
# Temporary until global backend is removed
|
50 |
+
@deprecated("With dispatcher enabled, this function is no-op. You can remove the function call.")
|
51 |
+
def set_audio_backend(backend: Optional[str]): # noqa
|
52 |
+
"""Set the global backend.
|
53 |
+
|
54 |
+
This is a no-op when dispatcher mode is enabled.
|
55 |
+
|
56 |
+
Args:
|
57 |
+
backend (str or None): Name of the backend.
|
58 |
+
One of ``"sox_io"`` or ``"soundfile"`` based on availability
|
59 |
+
of the system. If ``None`` is provided the current backend is unassigned.
|
60 |
+
"""
|
61 |
+
pass
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (1.77 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/backend.cpython-39.pyc
ADDED
Binary file (1.98 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/common.cpython-39.pyc
ADDED
Binary file (1.94 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/ffmpeg.cpython-39.pyc
ADDED
Binary file (8.03 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/soundfile.cpython-39.pyc
ADDED
Binary file (2.11 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/soundfile_backend.cpython-39.pyc
ADDED
Binary file (13.4 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/sox.cpython-39.pyc
ADDED
Binary file (3.1 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/__pycache__/utils.cpython-39.pyc
ADDED
Binary file (12.9 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_backend/backend.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from abc import ABC, abstractmethod
|
3 |
+
from typing import BinaryIO, Optional, Tuple, Union
|
4 |
+
|
5 |
+
from torch import Tensor
|
6 |
+
from torchaudio.io import CodecConfig
|
7 |
+
|
8 |
+
from .common import AudioMetaData
|
9 |
+
|
10 |
+
|
11 |
+
class Backend(ABC):
|
12 |
+
@staticmethod
|
13 |
+
@abstractmethod
|
14 |
+
def info(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], buffer_size: int = 4096) -> AudioMetaData:
|
15 |
+
raise NotImplementedError
|
16 |
+
|
17 |
+
@staticmethod
|
18 |
+
@abstractmethod
|
19 |
+
def load(
|
20 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
21 |
+
frame_offset: int = 0,
|
22 |
+
num_frames: int = -1,
|
23 |
+
normalize: bool = True,
|
24 |
+
channels_first: bool = True,
|
25 |
+
format: Optional[str] = None,
|
26 |
+
buffer_size: int = 4096,
|
27 |
+
) -> Tuple[Tensor, int]:
|
28 |
+
raise NotImplementedError
|
29 |
+
|
30 |
+
@staticmethod
|
31 |
+
@abstractmethod
|
32 |
+
def save(
|
33 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
34 |
+
src: Tensor,
|
35 |
+
sample_rate: int,
|
36 |
+
channels_first: bool = True,
|
37 |
+
format: Optional[str] = None,
|
38 |
+
encoding: Optional[str] = None,
|
39 |
+
bits_per_sample: Optional[int] = None,
|
40 |
+
buffer_size: int = 4096,
|
41 |
+
compression: Optional[Union[CodecConfig, float, int]] = None,
|
42 |
+
) -> None:
|
43 |
+
raise NotImplementedError
|
44 |
+
|
45 |
+
@staticmethod
|
46 |
+
@abstractmethod
|
47 |
+
def can_decode(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str]) -> bool:
|
48 |
+
raise NotImplementedError
|
49 |
+
|
50 |
+
@staticmethod
|
51 |
+
@abstractmethod
|
52 |
+
def can_encode(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str]) -> bool:
|
53 |
+
raise NotImplementedError
|
MLPY/Lib/site-packages/torchaudio/_backend/common.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class AudioMetaData:
|
2 |
+
"""AudioMetaData()
|
3 |
+
|
4 |
+
Return type of ``torchaudio.info`` function.
|
5 |
+
|
6 |
+
:ivar int sample_rate: Sample rate
|
7 |
+
:ivar int num_frames: The number of frames
|
8 |
+
:ivar int num_channels: The number of channels
|
9 |
+
:ivar int bits_per_sample: The number of bits per sample. This is 0 for lossy formats,
|
10 |
+
or when it cannot be accurately inferred.
|
11 |
+
:ivar str encoding: Audio encoding
|
12 |
+
The values encoding can take are one of the following:
|
13 |
+
|
14 |
+
* ``PCM_S``: Signed integer linear PCM
|
15 |
+
* ``PCM_U``: Unsigned integer linear PCM
|
16 |
+
* ``PCM_F``: Floating point linear PCM
|
17 |
+
* ``FLAC``: Flac, Free Lossless Audio Codec
|
18 |
+
* ``ULAW``: Mu-law
|
19 |
+
* ``ALAW``: A-law
|
20 |
+
* ``MP3`` : MP3, MPEG-1 Audio Layer III
|
21 |
+
* ``VORBIS``: OGG Vorbis
|
22 |
+
* ``AMR_WB``: Adaptive Multi-Rate Wideband
|
23 |
+
* ``AMR_NB``: Adaptive Multi-Rate Narrowband
|
24 |
+
* ``OPUS``: Opus
|
25 |
+
* ``HTK``: Single channel 16-bit PCM
|
26 |
+
* ``UNKNOWN`` : None of above
|
27 |
+
"""
|
28 |
+
|
29 |
+
def __init__(
|
30 |
+
self,
|
31 |
+
sample_rate: int,
|
32 |
+
num_frames: int,
|
33 |
+
num_channels: int,
|
34 |
+
bits_per_sample: int,
|
35 |
+
encoding: str,
|
36 |
+
):
|
37 |
+
self.sample_rate = sample_rate
|
38 |
+
self.num_frames = num_frames
|
39 |
+
self.num_channels = num_channels
|
40 |
+
self.bits_per_sample = bits_per_sample
|
41 |
+
self.encoding = encoding
|
42 |
+
|
43 |
+
def __str__(self):
|
44 |
+
return (
|
45 |
+
f"AudioMetaData("
|
46 |
+
f"sample_rate={self.sample_rate}, "
|
47 |
+
f"num_frames={self.num_frames}, "
|
48 |
+
f"num_channels={self.num_channels}, "
|
49 |
+
f"bits_per_sample={self.bits_per_sample}, "
|
50 |
+
f"encoding={self.encoding}"
|
51 |
+
f")"
|
52 |
+
)
|
MLPY/Lib/site-packages/torchaudio/_backend/ffmpeg.py
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import sys
|
4 |
+
from typing import BinaryIO, Optional, Tuple, Union
|
5 |
+
|
6 |
+
import torch
|
7 |
+
import torchaudio
|
8 |
+
|
9 |
+
from .backend import Backend
|
10 |
+
from .common import AudioMetaData
|
11 |
+
|
12 |
+
InputType = Union[BinaryIO, str, os.PathLike]
|
13 |
+
|
14 |
+
|
15 |
+
def info_audio(
|
16 |
+
src: InputType,
|
17 |
+
format: Optional[str],
|
18 |
+
buffer_size: int = 4096,
|
19 |
+
) -> AudioMetaData:
|
20 |
+
s = torchaudio.io.StreamReader(src, format, None, buffer_size)
|
21 |
+
sinfo = s.get_src_stream_info(s.default_audio_stream)
|
22 |
+
if sinfo.num_frames == 0:
|
23 |
+
waveform = _load_audio(s)
|
24 |
+
num_frames = waveform.size(1)
|
25 |
+
else:
|
26 |
+
num_frames = sinfo.num_frames
|
27 |
+
return AudioMetaData(
|
28 |
+
int(sinfo.sample_rate),
|
29 |
+
num_frames,
|
30 |
+
sinfo.num_channels,
|
31 |
+
sinfo.bits_per_sample,
|
32 |
+
sinfo.codec.upper(),
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
def _get_load_filter(
|
37 |
+
frame_offset: int = 0,
|
38 |
+
num_frames: int = -1,
|
39 |
+
convert: bool = True,
|
40 |
+
) -> Optional[str]:
|
41 |
+
if frame_offset < 0:
|
42 |
+
raise RuntimeError("Invalid argument: frame_offset must be non-negative. Found: {}".format(frame_offset))
|
43 |
+
if num_frames == 0 or num_frames < -1:
|
44 |
+
raise RuntimeError("Invalid argument: num_frames must be -1 or greater than 0. Found: {}".format(num_frames))
|
45 |
+
|
46 |
+
# All default values -> no filter
|
47 |
+
if frame_offset == 0 and num_frames == -1 and not convert:
|
48 |
+
return None
|
49 |
+
# Only convert
|
50 |
+
aformat = "aformat=sample_fmts=fltp"
|
51 |
+
if frame_offset == 0 and num_frames == -1 and convert:
|
52 |
+
return aformat
|
53 |
+
# At least one of frame_offset or num_frames has non-default value
|
54 |
+
if num_frames > 0:
|
55 |
+
atrim = "atrim=start_sample={}:end_sample={}".format(frame_offset, frame_offset + num_frames)
|
56 |
+
else:
|
57 |
+
atrim = "atrim=start_sample={}".format(frame_offset)
|
58 |
+
if not convert:
|
59 |
+
return atrim
|
60 |
+
return "{},{}".format(atrim, aformat)
|
61 |
+
|
62 |
+
|
63 |
+
def _load_audio(
|
64 |
+
s: "torchaudio.io.StreamReader",
|
65 |
+
filter: Optional[str] = None,
|
66 |
+
channels_first: bool = True,
|
67 |
+
) -> torch.Tensor:
|
68 |
+
s.add_audio_stream(-1, -1, filter_desc=filter)
|
69 |
+
s.process_all_packets()
|
70 |
+
chunk = s.pop_chunks()[0]
|
71 |
+
if chunk is None:
|
72 |
+
raise RuntimeError("Failed to decode audio.")
|
73 |
+
waveform = chunk._elem
|
74 |
+
return waveform.T if channels_first else waveform
|
75 |
+
|
76 |
+
|
77 |
+
def load_audio(
|
78 |
+
src: InputType,
|
79 |
+
frame_offset: int = 0,
|
80 |
+
num_frames: int = -1,
|
81 |
+
convert: bool = True,
|
82 |
+
channels_first: bool = True,
|
83 |
+
format: Optional[str] = None,
|
84 |
+
buffer_size: int = 4096,
|
85 |
+
) -> Tuple[torch.Tensor, int]:
|
86 |
+
if hasattr(src, "read") and format == "vorbis":
|
87 |
+
format = "ogg"
|
88 |
+
s = torchaudio.io.StreamReader(src, format, None, buffer_size)
|
89 |
+
sample_rate = int(s.get_src_stream_info(s.default_audio_stream).sample_rate)
|
90 |
+
filter = _get_load_filter(frame_offset, num_frames, convert)
|
91 |
+
waveform = _load_audio(s, filter, channels_first)
|
92 |
+
return waveform, sample_rate
|
93 |
+
|
94 |
+
|
95 |
+
def _get_sample_format(dtype: torch.dtype) -> str:
|
96 |
+
dtype_to_format = {
|
97 |
+
torch.uint8: "u8",
|
98 |
+
torch.int16: "s16",
|
99 |
+
torch.int32: "s32",
|
100 |
+
torch.int64: "s64",
|
101 |
+
torch.float32: "flt",
|
102 |
+
torch.float64: "dbl",
|
103 |
+
}
|
104 |
+
format = dtype_to_format.get(dtype)
|
105 |
+
if format is None:
|
106 |
+
raise ValueError(f"No format found for dtype {dtype}; dtype must be one of {list(dtype_to_format.keys())}.")
|
107 |
+
return format
|
108 |
+
|
109 |
+
|
110 |
+
def _native_endianness() -> str:
|
111 |
+
if sys.byteorder == "little":
|
112 |
+
return "le"
|
113 |
+
else:
|
114 |
+
return "be"
|
115 |
+
|
116 |
+
|
117 |
+
def _get_encoder_for_wav(encoding: str, bits_per_sample: int) -> str:
|
118 |
+
if bits_per_sample not in {None, 8, 16, 24, 32, 64}:
|
119 |
+
raise ValueError(f"Invalid bits_per_sample {bits_per_sample} for WAV encoding.")
|
120 |
+
endianness = _native_endianness()
|
121 |
+
if not encoding:
|
122 |
+
if not bits_per_sample:
|
123 |
+
# default to PCM S16
|
124 |
+
return f"pcm_s16{endianness}"
|
125 |
+
if bits_per_sample == 8:
|
126 |
+
return "pcm_u8"
|
127 |
+
return f"pcm_s{bits_per_sample}{endianness}"
|
128 |
+
if encoding == "PCM_S":
|
129 |
+
if not bits_per_sample:
|
130 |
+
bits_per_sample = 16
|
131 |
+
if bits_per_sample == 8:
|
132 |
+
raise ValueError("For WAV signed PCM, 8-bit encoding is not supported.")
|
133 |
+
return f"pcm_s{bits_per_sample}{endianness}"
|
134 |
+
if encoding == "PCM_U":
|
135 |
+
if bits_per_sample in (None, 8):
|
136 |
+
return "pcm_u8"
|
137 |
+
raise ValueError("For WAV unsigned PCM, only 8-bit encoding is supported.")
|
138 |
+
if encoding == "PCM_F":
|
139 |
+
if not bits_per_sample:
|
140 |
+
bits_per_sample = 32
|
141 |
+
if bits_per_sample in (32, 64):
|
142 |
+
return f"pcm_f{bits_per_sample}{endianness}"
|
143 |
+
raise ValueError("For WAV float PCM, only 32- and 64-bit encodings are supported.")
|
144 |
+
if encoding == "ULAW":
|
145 |
+
if bits_per_sample in (None, 8):
|
146 |
+
return "pcm_mulaw"
|
147 |
+
raise ValueError("For WAV PCM mu-law, only 8-bit encoding is supported.")
|
148 |
+
if encoding == "ALAW":
|
149 |
+
if bits_per_sample in (None, 8):
|
150 |
+
return "pcm_alaw"
|
151 |
+
raise ValueError("For WAV PCM A-law, only 8-bit encoding is supported.")
|
152 |
+
raise ValueError(f"WAV encoding {encoding} is not supported.")
|
153 |
+
|
154 |
+
|
155 |
+
def _get_flac_sample_fmt(bps):
|
156 |
+
if bps is None or bps == 16:
|
157 |
+
return "s16"
|
158 |
+
if bps == 24:
|
159 |
+
return "s32"
|
160 |
+
raise ValueError(f"FLAC only supports bits_per_sample values of 16 and 24 ({bps} specified).")
|
161 |
+
|
162 |
+
|
163 |
+
def _parse_save_args(
|
164 |
+
ext: Optional[str],
|
165 |
+
format: Optional[str],
|
166 |
+
encoding: Optional[str],
|
167 |
+
bps: Optional[int],
|
168 |
+
):
|
169 |
+
# torchaudio's save function accepts the followings, which do not 1to1 map
|
170 |
+
# to FFmpeg.
|
171 |
+
#
|
172 |
+
# - format: audio format
|
173 |
+
# - bits_per_sample: encoder sample format
|
174 |
+
# - encoding: such as PCM_U8.
|
175 |
+
#
|
176 |
+
# In FFmpeg, format is specified with the following three (and more)
|
177 |
+
#
|
178 |
+
# - muxer: could be audio format or container format.
|
179 |
+
# the one we passed to the constructor of StreamWriter
|
180 |
+
# - encoder: the audio encoder used to encode audio
|
181 |
+
# - encoder sample format: the format used by encoder to encode audio.
|
182 |
+
#
|
183 |
+
# If encoder sample format is different from source sample format, StreamWriter
|
184 |
+
# will insert a filter automatically.
|
185 |
+
#
|
186 |
+
def _type(spec):
|
187 |
+
# either format is exactly the specified one
|
188 |
+
# or extension matches to the spec AND there is no format override.
|
189 |
+
return format == spec or (format is None and ext == spec)
|
190 |
+
|
191 |
+
if _type("wav") or _type("amb"):
|
192 |
+
# wav is special because it supports different encoding through encoders
|
193 |
+
# each encoder only supports one encoder format
|
194 |
+
#
|
195 |
+
# amb format is a special case originated from libsox.
|
196 |
+
# It is basically a WAV format, with slight modification.
|
197 |
+
# https://github.com/chirlu/sox/commit/4a4ea33edbca5972a1ed8933cc3512c7302fa67a#diff-39171191a858add9df87f5f210a34a776ac2c026842ae6db6ce97f5e68836795
|
198 |
+
# It is a format so that decoders will recognize it as ambisonic.
|
199 |
+
# https://www.ambisonia.com/Members/mleese/file-format-for-b-format/
|
200 |
+
# FFmpeg does not recognize amb because it is basically a WAV format.
|
201 |
+
muxer = "wav"
|
202 |
+
encoder = _get_encoder_for_wav(encoding, bps)
|
203 |
+
sample_fmt = None
|
204 |
+
elif _type("vorbis"):
|
205 |
+
# FFpmeg does not recognize vorbis extension, while libsox used to do.
|
206 |
+
# For the sake of bakward compatibility, (and the simplicity),
|
207 |
+
# we support the case where users want to do save("foo.vorbis")
|
208 |
+
muxer = "ogg"
|
209 |
+
encoder = "vorbis"
|
210 |
+
sample_fmt = None
|
211 |
+
else:
|
212 |
+
muxer = format
|
213 |
+
encoder = None
|
214 |
+
sample_fmt = None
|
215 |
+
if _type("flac"):
|
216 |
+
sample_fmt = _get_flac_sample_fmt(bps)
|
217 |
+
if _type("ogg"):
|
218 |
+
sample_fmt = _get_flac_sample_fmt(bps)
|
219 |
+
return muxer, encoder, sample_fmt
|
220 |
+
|
221 |
+
|
222 |
+
def save_audio(
|
223 |
+
uri: InputType,
|
224 |
+
src: torch.Tensor,
|
225 |
+
sample_rate: int,
|
226 |
+
channels_first: bool = True,
|
227 |
+
format: Optional[str] = None,
|
228 |
+
encoding: Optional[str] = None,
|
229 |
+
bits_per_sample: Optional[int] = None,
|
230 |
+
buffer_size: int = 4096,
|
231 |
+
compression: Optional[torchaudio.io.CodecConfig] = None,
|
232 |
+
) -> None:
|
233 |
+
ext = None
|
234 |
+
if hasattr(uri, "write"):
|
235 |
+
if format is None:
|
236 |
+
raise RuntimeError("'format' is required when saving to file object.")
|
237 |
+
else:
|
238 |
+
uri = os.path.normpath(uri)
|
239 |
+
if tokens := str(uri).split(".")[1:]:
|
240 |
+
ext = tokens[-1].lower()
|
241 |
+
|
242 |
+
muxer, encoder, enc_fmt = _parse_save_args(ext, format, encoding, bits_per_sample)
|
243 |
+
|
244 |
+
if channels_first:
|
245 |
+
src = src.T
|
246 |
+
|
247 |
+
s = torchaudio.io.StreamWriter(uri, format=muxer, buffer_size=buffer_size)
|
248 |
+
s.add_audio_stream(
|
249 |
+
sample_rate,
|
250 |
+
num_channels=src.size(-1),
|
251 |
+
format=_get_sample_format(src.dtype),
|
252 |
+
encoder=encoder,
|
253 |
+
encoder_format=enc_fmt,
|
254 |
+
codec_config=compression,
|
255 |
+
)
|
256 |
+
with s.open():
|
257 |
+
s.write_audio_chunk(0, src)
|
258 |
+
|
259 |
+
|
260 |
+
def _map_encoding(encoding: str) -> str:
|
261 |
+
for dst in ["PCM_S", "PCM_U", "PCM_F"]:
|
262 |
+
if dst in encoding:
|
263 |
+
return dst
|
264 |
+
if encoding == "PCM_MULAW":
|
265 |
+
return "ULAW"
|
266 |
+
elif encoding == "PCM_ALAW":
|
267 |
+
return "ALAW"
|
268 |
+
return encoding
|
269 |
+
|
270 |
+
|
271 |
+
def _get_bits_per_sample(encoding: str, bits_per_sample: int) -> str:
|
272 |
+
if m := re.search(r"PCM_\w(\d+)\w*", encoding):
|
273 |
+
return int(m.group(1))
|
274 |
+
elif encoding in ["PCM_ALAW", "PCM_MULAW"]:
|
275 |
+
return 8
|
276 |
+
return bits_per_sample
|
277 |
+
|
278 |
+
|
279 |
+
class FFmpegBackend(Backend):
|
280 |
+
@staticmethod
|
281 |
+
def info(uri: InputType, format: Optional[str], buffer_size: int = 4096) -> AudioMetaData:
|
282 |
+
metadata = info_audio(uri, format, buffer_size)
|
283 |
+
metadata.bits_per_sample = _get_bits_per_sample(metadata.encoding, metadata.bits_per_sample)
|
284 |
+
metadata.encoding = _map_encoding(metadata.encoding)
|
285 |
+
return metadata
|
286 |
+
|
287 |
+
@staticmethod
|
288 |
+
def load(
|
289 |
+
uri: InputType,
|
290 |
+
frame_offset: int = 0,
|
291 |
+
num_frames: int = -1,
|
292 |
+
normalize: bool = True,
|
293 |
+
channels_first: bool = True,
|
294 |
+
format: Optional[str] = None,
|
295 |
+
buffer_size: int = 4096,
|
296 |
+
) -> Tuple[torch.Tensor, int]:
|
297 |
+
return load_audio(uri, frame_offset, num_frames, normalize, channels_first, format)
|
298 |
+
|
299 |
+
@staticmethod
|
300 |
+
def save(
|
301 |
+
uri: InputType,
|
302 |
+
src: torch.Tensor,
|
303 |
+
sample_rate: int,
|
304 |
+
channels_first: bool = True,
|
305 |
+
format: Optional[str] = None,
|
306 |
+
encoding: Optional[str] = None,
|
307 |
+
bits_per_sample: Optional[int] = None,
|
308 |
+
buffer_size: int = 4096,
|
309 |
+
compression: Optional[Union[torchaudio.io.CodecConfig, float, int]] = None,
|
310 |
+
) -> None:
|
311 |
+
if not isinstance(compression, (torchaudio.io.CodecConfig, type(None))):
|
312 |
+
raise ValueError(
|
313 |
+
"FFmpeg backend expects non-`None` value for argument `compression` to be of ",
|
314 |
+
f"type `torchaudio.io.CodecConfig`, but received value of type {type(compression)}",
|
315 |
+
)
|
316 |
+
save_audio(
|
317 |
+
uri,
|
318 |
+
src,
|
319 |
+
sample_rate,
|
320 |
+
channels_first,
|
321 |
+
format,
|
322 |
+
encoding,
|
323 |
+
bits_per_sample,
|
324 |
+
buffer_size,
|
325 |
+
compression,
|
326 |
+
)
|
327 |
+
|
328 |
+
@staticmethod
|
329 |
+
def can_decode(uri: InputType, format: Optional[str]) -> bool:
|
330 |
+
return True
|
331 |
+
|
332 |
+
@staticmethod
|
333 |
+
def can_encode(uri: InputType, format: Optional[str]) -> bool:
|
334 |
+
return True
|
MLPY/Lib/site-packages/torchaudio/_backend/soundfile.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import BinaryIO, Optional, Tuple, Union
|
3 |
+
|
4 |
+
import torch
|
5 |
+
from torchaudio.io import CodecConfig
|
6 |
+
|
7 |
+
from . import soundfile_backend
|
8 |
+
from .backend import Backend
|
9 |
+
from .common import AudioMetaData
|
10 |
+
|
11 |
+
|
12 |
+
class SoundfileBackend(Backend):
|
13 |
+
@staticmethod
|
14 |
+
def info(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], buffer_size: int = 4096) -> AudioMetaData:
|
15 |
+
return soundfile_backend.info(uri, format)
|
16 |
+
|
17 |
+
@staticmethod
|
18 |
+
def load(
|
19 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
20 |
+
frame_offset: int = 0,
|
21 |
+
num_frames: int = -1,
|
22 |
+
normalize: bool = True,
|
23 |
+
channels_first: bool = True,
|
24 |
+
format: Optional[str] = None,
|
25 |
+
buffer_size: int = 4096,
|
26 |
+
) -> Tuple[torch.Tensor, int]:
|
27 |
+
return soundfile_backend.load(uri, frame_offset, num_frames, normalize, channels_first, format)
|
28 |
+
|
29 |
+
@staticmethod
|
30 |
+
def save(
|
31 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
32 |
+
src: torch.Tensor,
|
33 |
+
sample_rate: int,
|
34 |
+
channels_first: bool = True,
|
35 |
+
format: Optional[str] = None,
|
36 |
+
encoding: Optional[str] = None,
|
37 |
+
bits_per_sample: Optional[int] = None,
|
38 |
+
buffer_size: int = 4096,
|
39 |
+
compression: Optional[Union[CodecConfig, float, int]] = None,
|
40 |
+
) -> None:
|
41 |
+
if compression:
|
42 |
+
raise ValueError("soundfile backend does not support argument `compression`.")
|
43 |
+
|
44 |
+
soundfile_backend.save(
|
45 |
+
uri, src, sample_rate, channels_first, format=format, encoding=encoding, bits_per_sample=bits_per_sample
|
46 |
+
)
|
47 |
+
|
48 |
+
@staticmethod
|
49 |
+
def can_decode(uri, format) -> bool:
|
50 |
+
return True
|
51 |
+
|
52 |
+
@staticmethod
|
53 |
+
def can_encode(uri, format) -> bool:
|
54 |
+
return True
|
MLPY/Lib/site-packages/torchaudio/_backend/soundfile_backend.py
ADDED
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""The new soundfile backend which will become default in 0.8.0 onward"""
|
2 |
+
import warnings
|
3 |
+
from typing import Optional, Tuple
|
4 |
+
|
5 |
+
import torch
|
6 |
+
from torchaudio._internal import module_utils as _mod_utils
|
7 |
+
|
8 |
+
from .common import AudioMetaData
|
9 |
+
|
10 |
+
|
11 |
+
_IS_SOUNDFILE_AVAILABLE = False
|
12 |
+
|
13 |
+
# TODO: import soundfile only when it is used.
|
14 |
+
if _mod_utils.is_module_available("soundfile"):
|
15 |
+
try:
|
16 |
+
import soundfile
|
17 |
+
|
18 |
+
_requires_soundfile = _mod_utils.no_op
|
19 |
+
_IS_SOUNDFILE_AVAILABLE = True
|
20 |
+
except Exception:
|
21 |
+
_requires_soundfile = _mod_utils.fail_with_message(
|
22 |
+
"requires soundfile, but we failed to import it. Please check the installation of soundfile."
|
23 |
+
)
|
24 |
+
else:
|
25 |
+
_requires_soundfile = _mod_utils.fail_with_message(
|
26 |
+
"requires soundfile, but it is not installed. Please install soundfile."
|
27 |
+
)
|
28 |
+
|
29 |
+
|
30 |
+
# Mapping from soundfile subtype to number of bits per sample.
|
31 |
+
# This is mostly heuristical and the value is set to 0 when it is irrelevant
|
32 |
+
# (lossy formats) or when it can't be inferred.
|
33 |
+
# For ADPCM (and G72X) subtypes, it's hard to infer the bit depth because it's not part of the standard:
|
34 |
+
# According to https://en.wikipedia.org/wiki/Adaptive_differential_pulse-code_modulation#In_telephony,
|
35 |
+
# the default seems to be 8 bits but it can be compressed further to 4 bits.
|
36 |
+
# The dict is inspired from
|
37 |
+
# https://github.com/bastibe/python-soundfile/blob/744efb4b01abc72498a96b09115b42a4cabd85e4/soundfile.py#L66-L94
|
38 |
+
_SUBTYPE_TO_BITS_PER_SAMPLE = {
|
39 |
+
"PCM_S8": 8, # Signed 8 bit data
|
40 |
+
"PCM_16": 16, # Signed 16 bit data
|
41 |
+
"PCM_24": 24, # Signed 24 bit data
|
42 |
+
"PCM_32": 32, # Signed 32 bit data
|
43 |
+
"PCM_U8": 8, # Unsigned 8 bit data (WAV and RAW only)
|
44 |
+
"FLOAT": 32, # 32 bit float data
|
45 |
+
"DOUBLE": 64, # 64 bit float data
|
46 |
+
"ULAW": 8, # U-Law encoded. See https://en.wikipedia.org/wiki/G.711#Types
|
47 |
+
"ALAW": 8, # A-Law encoded. See https://en.wikipedia.org/wiki/G.711#Types
|
48 |
+
"IMA_ADPCM": 0, # IMA ADPCM.
|
49 |
+
"MS_ADPCM": 0, # Microsoft ADPCM.
|
50 |
+
"GSM610": 0, # GSM 6.10 encoding. (Wikipedia says 1.625 bit depth?? https://en.wikipedia.org/wiki/Full_Rate)
|
51 |
+
"VOX_ADPCM": 0, # OKI / Dialogix ADPCM
|
52 |
+
"G721_32": 0, # 32kbs G721 ADPCM encoding.
|
53 |
+
"G723_24": 0, # 24kbs G723 ADPCM encoding.
|
54 |
+
"G723_40": 0, # 40kbs G723 ADPCM encoding.
|
55 |
+
"DWVW_12": 12, # 12 bit Delta Width Variable Word encoding.
|
56 |
+
"DWVW_16": 16, # 16 bit Delta Width Variable Word encoding.
|
57 |
+
"DWVW_24": 24, # 24 bit Delta Width Variable Word encoding.
|
58 |
+
"DWVW_N": 0, # N bit Delta Width Variable Word encoding.
|
59 |
+
"DPCM_8": 8, # 8 bit differential PCM (XI only)
|
60 |
+
"DPCM_16": 16, # 16 bit differential PCM (XI only)
|
61 |
+
"VORBIS": 0, # Xiph Vorbis encoding. (lossy)
|
62 |
+
"ALAC_16": 16, # Apple Lossless Audio Codec (16 bit).
|
63 |
+
"ALAC_20": 20, # Apple Lossless Audio Codec (20 bit).
|
64 |
+
"ALAC_24": 24, # Apple Lossless Audio Codec (24 bit).
|
65 |
+
"ALAC_32": 32, # Apple Lossless Audio Codec (32 bit).
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
def _get_bit_depth(subtype):
|
70 |
+
if subtype not in _SUBTYPE_TO_BITS_PER_SAMPLE:
|
71 |
+
warnings.warn(
|
72 |
+
f"The {subtype} subtype is unknown to TorchAudio. As a result, the bits_per_sample "
|
73 |
+
"attribute will be set to 0. If you are seeing this warning, please "
|
74 |
+
"report by opening an issue on github (after checking for existing/closed ones). "
|
75 |
+
"You may otherwise ignore this warning."
|
76 |
+
)
|
77 |
+
return _SUBTYPE_TO_BITS_PER_SAMPLE.get(subtype, 0)
|
78 |
+
|
79 |
+
|
80 |
+
_SUBTYPE_TO_ENCODING = {
|
81 |
+
"PCM_S8": "PCM_S",
|
82 |
+
"PCM_16": "PCM_S",
|
83 |
+
"PCM_24": "PCM_S",
|
84 |
+
"PCM_32": "PCM_S",
|
85 |
+
"PCM_U8": "PCM_U",
|
86 |
+
"FLOAT": "PCM_F",
|
87 |
+
"DOUBLE": "PCM_F",
|
88 |
+
"ULAW": "ULAW",
|
89 |
+
"ALAW": "ALAW",
|
90 |
+
"VORBIS": "VORBIS",
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
def _get_encoding(format: str, subtype: str):
|
95 |
+
if format == "FLAC":
|
96 |
+
return "FLAC"
|
97 |
+
return _SUBTYPE_TO_ENCODING.get(subtype, "UNKNOWN")
|
98 |
+
|
99 |
+
|
100 |
+
@_requires_soundfile
|
101 |
+
def info(filepath: str, format: Optional[str] = None) -> AudioMetaData:
|
102 |
+
"""Get signal information of an audio file.
|
103 |
+
|
104 |
+
Note:
|
105 |
+
``filepath`` argument is intentionally annotated as ``str`` only, even though it accepts
|
106 |
+
``pathlib.Path`` object as well. This is for the consistency with ``"sox_io"`` backend,
|
107 |
+
which has a restriction on type annotation due to TorchScript compiler compatiblity.
|
108 |
+
|
109 |
+
Args:
|
110 |
+
filepath (path-like object or file-like object):
|
111 |
+
Source of audio data.
|
112 |
+
format (str or None, optional):
|
113 |
+
Not used. PySoundFile does not accept format hint.
|
114 |
+
|
115 |
+
Returns:
|
116 |
+
AudioMetaData: meta data of the given audio.
|
117 |
+
|
118 |
+
"""
|
119 |
+
sinfo = soundfile.info(filepath)
|
120 |
+
return AudioMetaData(
|
121 |
+
sinfo.samplerate,
|
122 |
+
sinfo.frames,
|
123 |
+
sinfo.channels,
|
124 |
+
bits_per_sample=_get_bit_depth(sinfo.subtype),
|
125 |
+
encoding=_get_encoding(sinfo.format, sinfo.subtype),
|
126 |
+
)
|
127 |
+
|
128 |
+
|
129 |
+
_SUBTYPE2DTYPE = {
|
130 |
+
"PCM_S8": "int8",
|
131 |
+
"PCM_U8": "uint8",
|
132 |
+
"PCM_16": "int16",
|
133 |
+
"PCM_32": "int32",
|
134 |
+
"FLOAT": "float32",
|
135 |
+
"DOUBLE": "float64",
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
+
@_requires_soundfile
|
140 |
+
def load(
|
141 |
+
filepath: str,
|
142 |
+
frame_offset: int = 0,
|
143 |
+
num_frames: int = -1,
|
144 |
+
normalize: bool = True,
|
145 |
+
channels_first: bool = True,
|
146 |
+
format: Optional[str] = None,
|
147 |
+
) -> Tuple[torch.Tensor, int]:
|
148 |
+
"""Load audio data from file.
|
149 |
+
|
150 |
+
Note:
|
151 |
+
The formats this function can handle depend on the soundfile installation.
|
152 |
+
This function is tested on the following formats;
|
153 |
+
|
154 |
+
* WAV
|
155 |
+
|
156 |
+
* 32-bit floating-point
|
157 |
+
* 32-bit signed integer
|
158 |
+
* 16-bit signed integer
|
159 |
+
* 8-bit unsigned integer
|
160 |
+
|
161 |
+
* FLAC
|
162 |
+
* OGG/VORBIS
|
163 |
+
* SPHERE
|
164 |
+
|
165 |
+
By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with
|
166 |
+
``float32`` dtype, and the shape of `[channel, time]`.
|
167 |
+
|
168 |
+
.. warning::
|
169 |
+
|
170 |
+
``normalize`` argument does not perform volume normalization.
|
171 |
+
It only converts the sample type to `torch.float32` from the native sample
|
172 |
+
type.
|
173 |
+
|
174 |
+
When the input format is WAV with integer type, such as 32-bit signed integer, 16-bit
|
175 |
+
signed integer, 24-bit signed integer, and 8-bit unsigned integer, by providing ``normalize=False``,
|
176 |
+
this function can return integer Tensor, where the samples are expressed within the whole range
|
177 |
+
of the corresponding dtype, that is, ``int32`` tensor for 32-bit signed PCM,
|
178 |
+
``int16`` for 16-bit signed PCM and ``uint8`` for 8-bit unsigned PCM. Since torch does not
|
179 |
+
support ``int24`` dtype, 24-bit signed PCM are converted to ``int32`` tensors.
|
180 |
+
|
181 |
+
``normalize`` argument has no effect on 32-bit floating-point WAV and other formats, such as
|
182 |
+
``flac`` and ``mp3``.
|
183 |
+
|
184 |
+
For these formats, this function always returns ``float32`` Tensor with values.
|
185 |
+
|
186 |
+
Note:
|
187 |
+
``filepath`` argument is intentionally annotated as ``str`` only, even though it accepts
|
188 |
+
``pathlib.Path`` object as well. This is for the consistency with ``"sox_io"`` backend,
|
189 |
+
which has a restriction on type annotation due to TorchScript compiler compatiblity.
|
190 |
+
|
191 |
+
Args:
|
192 |
+
filepath (path-like object or file-like object):
|
193 |
+
Source of audio data.
|
194 |
+
frame_offset (int, optional):
|
195 |
+
Number of frames to skip before start reading data.
|
196 |
+
num_frames (int, optional):
|
197 |
+
Maximum number of frames to read. ``-1`` reads all the remaining samples,
|
198 |
+
starting from ``frame_offset``.
|
199 |
+
This function may return the less number of frames if there is not enough
|
200 |
+
frames in the given file.
|
201 |
+
normalize (bool, optional):
|
202 |
+
When ``True``, this function converts the native sample type to ``float32``.
|
203 |
+
Default: ``True``.
|
204 |
+
|
205 |
+
If input file is integer WAV, giving ``False`` will change the resulting Tensor type to
|
206 |
+
integer type.
|
207 |
+
This argument has no effect for formats other than integer WAV type.
|
208 |
+
|
209 |
+
channels_first (bool, optional):
|
210 |
+
When True, the returned Tensor has dimension `[channel, time]`.
|
211 |
+
Otherwise, the returned Tensor's dimension is `[time, channel]`.
|
212 |
+
format (str or None, optional):
|
213 |
+
Not used. PySoundFile does not accept format hint.
|
214 |
+
|
215 |
+
Returns:
|
216 |
+
(torch.Tensor, int): Resulting Tensor and sample rate.
|
217 |
+
If the input file has integer wav format and normalization is off, then it has
|
218 |
+
integer type, else ``float32`` type. If ``channels_first=True``, it has
|
219 |
+
`[channel, time]` else `[time, channel]`.
|
220 |
+
"""
|
221 |
+
with soundfile.SoundFile(filepath, "r") as file_:
|
222 |
+
if file_.format != "WAV" or normalize:
|
223 |
+
dtype = "float32"
|
224 |
+
elif file_.subtype not in _SUBTYPE2DTYPE:
|
225 |
+
raise ValueError(f"Unsupported subtype: {file_.subtype}")
|
226 |
+
else:
|
227 |
+
dtype = _SUBTYPE2DTYPE[file_.subtype]
|
228 |
+
|
229 |
+
frames = file_._prepare_read(frame_offset, None, num_frames)
|
230 |
+
waveform = file_.read(frames, dtype, always_2d=True)
|
231 |
+
sample_rate = file_.samplerate
|
232 |
+
|
233 |
+
waveform = torch.from_numpy(waveform)
|
234 |
+
if channels_first:
|
235 |
+
waveform = waveform.t()
|
236 |
+
return waveform, sample_rate
|
237 |
+
|
238 |
+
|
239 |
+
def _get_subtype_for_wav(dtype: torch.dtype, encoding: str, bits_per_sample: int):
|
240 |
+
if not encoding:
|
241 |
+
if not bits_per_sample:
|
242 |
+
subtype = {
|
243 |
+
torch.uint8: "PCM_U8",
|
244 |
+
torch.int16: "PCM_16",
|
245 |
+
torch.int32: "PCM_32",
|
246 |
+
torch.float32: "FLOAT",
|
247 |
+
torch.float64: "DOUBLE",
|
248 |
+
}.get(dtype)
|
249 |
+
if not subtype:
|
250 |
+
raise ValueError(f"Unsupported dtype for wav: {dtype}")
|
251 |
+
return subtype
|
252 |
+
if bits_per_sample == 8:
|
253 |
+
return "PCM_U8"
|
254 |
+
return f"PCM_{bits_per_sample}"
|
255 |
+
if encoding == "PCM_S":
|
256 |
+
if not bits_per_sample:
|
257 |
+
return "PCM_32"
|
258 |
+
if bits_per_sample == 8:
|
259 |
+
raise ValueError("wav does not support 8-bit signed PCM encoding.")
|
260 |
+
return f"PCM_{bits_per_sample}"
|
261 |
+
if encoding == "PCM_U":
|
262 |
+
if bits_per_sample in (None, 8):
|
263 |
+
return "PCM_U8"
|
264 |
+
raise ValueError("wav only supports 8-bit unsigned PCM encoding.")
|
265 |
+
if encoding == "PCM_F":
|
266 |
+
if bits_per_sample in (None, 32):
|
267 |
+
return "FLOAT"
|
268 |
+
if bits_per_sample == 64:
|
269 |
+
return "DOUBLE"
|
270 |
+
raise ValueError("wav only supports 32/64-bit float PCM encoding.")
|
271 |
+
if encoding == "ULAW":
|
272 |
+
if bits_per_sample in (None, 8):
|
273 |
+
return "ULAW"
|
274 |
+
raise ValueError("wav only supports 8-bit mu-law encoding.")
|
275 |
+
if encoding == "ALAW":
|
276 |
+
if bits_per_sample in (None, 8):
|
277 |
+
return "ALAW"
|
278 |
+
raise ValueError("wav only supports 8-bit a-law encoding.")
|
279 |
+
raise ValueError(f"wav does not support {encoding}.")
|
280 |
+
|
281 |
+
|
282 |
+
def _get_subtype_for_sphere(encoding: str, bits_per_sample: int):
|
283 |
+
if encoding in (None, "PCM_S"):
|
284 |
+
return f"PCM_{bits_per_sample}" if bits_per_sample else "PCM_32"
|
285 |
+
if encoding in ("PCM_U", "PCM_F"):
|
286 |
+
raise ValueError(f"sph does not support {encoding} encoding.")
|
287 |
+
if encoding == "ULAW":
|
288 |
+
if bits_per_sample in (None, 8):
|
289 |
+
return "ULAW"
|
290 |
+
raise ValueError("sph only supports 8-bit for mu-law encoding.")
|
291 |
+
if encoding == "ALAW":
|
292 |
+
return "ALAW"
|
293 |
+
raise ValueError(f"sph does not support {encoding}.")
|
294 |
+
|
295 |
+
|
296 |
+
def _get_subtype(dtype: torch.dtype, format: str, encoding: str, bits_per_sample: int):
|
297 |
+
if format == "wav":
|
298 |
+
return _get_subtype_for_wav(dtype, encoding, bits_per_sample)
|
299 |
+
if format == "flac":
|
300 |
+
if encoding:
|
301 |
+
raise ValueError("flac does not support encoding.")
|
302 |
+
if not bits_per_sample:
|
303 |
+
return "PCM_16"
|
304 |
+
if bits_per_sample > 24:
|
305 |
+
raise ValueError("flac does not support bits_per_sample > 24.")
|
306 |
+
return "PCM_S8" if bits_per_sample == 8 else f"PCM_{bits_per_sample}"
|
307 |
+
if format in ("ogg", "vorbis"):
|
308 |
+
if bits_per_sample:
|
309 |
+
raise ValueError("ogg/vorbis does not support bits_per_sample.")
|
310 |
+
if encoding is None or encoding == "vorbis":
|
311 |
+
return "VORBIS"
|
312 |
+
if encoding == "opus":
|
313 |
+
return "OPUS"
|
314 |
+
raise ValueError(f"Unexpected encoding: {encoding}")
|
315 |
+
if format == "mp3":
|
316 |
+
return "MPEG_LAYER_III"
|
317 |
+
if format == "sph":
|
318 |
+
return _get_subtype_for_sphere(encoding, bits_per_sample)
|
319 |
+
if format in ("nis", "nist"):
|
320 |
+
return "PCM_16"
|
321 |
+
raise ValueError(f"Unsupported format: {format}")
|
322 |
+
|
323 |
+
|
324 |
+
@_requires_soundfile
|
325 |
+
def save(
|
326 |
+
filepath: str,
|
327 |
+
src: torch.Tensor,
|
328 |
+
sample_rate: int,
|
329 |
+
channels_first: bool = True,
|
330 |
+
compression: Optional[float] = None,
|
331 |
+
format: Optional[str] = None,
|
332 |
+
encoding: Optional[str] = None,
|
333 |
+
bits_per_sample: Optional[int] = None,
|
334 |
+
):
|
335 |
+
"""Save audio data to file.
|
336 |
+
|
337 |
+
Note:
|
338 |
+
The formats this function can handle depend on the soundfile installation.
|
339 |
+
This function is tested on the following formats;
|
340 |
+
|
341 |
+
* WAV
|
342 |
+
|
343 |
+
* 32-bit floating-point
|
344 |
+
* 32-bit signed integer
|
345 |
+
* 16-bit signed integer
|
346 |
+
* 8-bit unsigned integer
|
347 |
+
|
348 |
+
* FLAC
|
349 |
+
* OGG/VORBIS
|
350 |
+
* SPHERE
|
351 |
+
|
352 |
+
Note:
|
353 |
+
``filepath`` argument is intentionally annotated as ``str`` only, even though it accepts
|
354 |
+
``pathlib.Path`` object as well. This is for the consistency with ``"sox_io"`` backend,
|
355 |
+
which has a restriction on type annotation due to TorchScript compiler compatiblity.
|
356 |
+
|
357 |
+
Args:
|
358 |
+
filepath (str or pathlib.Path): Path to audio file.
|
359 |
+
src (torch.Tensor): Audio data to save. must be 2D tensor.
|
360 |
+
sample_rate (int): sampling rate
|
361 |
+
channels_first (bool, optional): If ``True``, the given tensor is interpreted as `[channel, time]`,
|
362 |
+
otherwise `[time, channel]`.
|
363 |
+
compression (float of None, optional): Not used.
|
364 |
+
It is here only for interface compatibility reson with "sox_io" backend.
|
365 |
+
format (str or None, optional): Override the audio format.
|
366 |
+
When ``filepath`` argument is path-like object, audio format is
|
367 |
+
inferred from file extension. If the file extension is missing or
|
368 |
+
different, you can specify the correct format with this argument.
|
369 |
+
|
370 |
+
When ``filepath`` argument is file-like object,
|
371 |
+
this argument is required.
|
372 |
+
|
373 |
+
Valid values are ``"wav"``, ``"ogg"``, ``"vorbis"``,
|
374 |
+
``"flac"`` and ``"sph"``.
|
375 |
+
encoding (str or None, optional): Changes the encoding for supported formats.
|
376 |
+
This argument is effective only for supported formats, sush as
|
377 |
+
``"wav"``, ``""flac"`` and ``"sph"``. Valid values are;
|
378 |
+
|
379 |
+
- ``"PCM_S"`` (signed integer Linear PCM)
|
380 |
+
- ``"PCM_U"`` (unsigned integer Linear PCM)
|
381 |
+
- ``"PCM_F"`` (floating point PCM)
|
382 |
+
- ``"ULAW"`` (mu-law)
|
383 |
+
- ``"ALAW"`` (a-law)
|
384 |
+
|
385 |
+
bits_per_sample (int or None, optional): Changes the bit depth for the
|
386 |
+
supported formats.
|
387 |
+
When ``format`` is one of ``"wav"``, ``"flac"`` or ``"sph"``,
|
388 |
+
you can change the bit depth.
|
389 |
+
Valid values are ``8``, ``16``, ``24``, ``32`` and ``64``.
|
390 |
+
|
391 |
+
Supported formats/encodings/bit depth/compression are:
|
392 |
+
|
393 |
+
``"wav"``
|
394 |
+
- 32-bit floating-point PCM
|
395 |
+
- 32-bit signed integer PCM
|
396 |
+
- 24-bit signed integer PCM
|
397 |
+
- 16-bit signed integer PCM
|
398 |
+
- 8-bit unsigned integer PCM
|
399 |
+
- 8-bit mu-law
|
400 |
+
- 8-bit a-law
|
401 |
+
|
402 |
+
Note:
|
403 |
+
Default encoding/bit depth is determined by the dtype of
|
404 |
+
the input Tensor.
|
405 |
+
|
406 |
+
``"flac"``
|
407 |
+
- 8-bit
|
408 |
+
- 16-bit (default)
|
409 |
+
- 24-bit
|
410 |
+
|
411 |
+
``"ogg"``, ``"vorbis"``
|
412 |
+
- Doesn't accept changing configuration.
|
413 |
+
|
414 |
+
``"sph"``
|
415 |
+
- 8-bit signed integer PCM
|
416 |
+
- 16-bit signed integer PCM
|
417 |
+
- 24-bit signed integer PCM
|
418 |
+
- 32-bit signed integer PCM (default)
|
419 |
+
- 8-bit mu-law
|
420 |
+
- 8-bit a-law
|
421 |
+
- 16-bit a-law
|
422 |
+
- 24-bit a-law
|
423 |
+
- 32-bit a-law
|
424 |
+
|
425 |
+
"""
|
426 |
+
if src.ndim != 2:
|
427 |
+
raise ValueError(f"Expected 2D Tensor, got {src.ndim}D.")
|
428 |
+
if compression is not None:
|
429 |
+
warnings.warn(
|
430 |
+
'`save` function of "soundfile" backend does not support "compression" parameter. '
|
431 |
+
"The argument is silently ignored."
|
432 |
+
)
|
433 |
+
if hasattr(filepath, "write"):
|
434 |
+
if format is None:
|
435 |
+
raise RuntimeError("`format` is required when saving to file object.")
|
436 |
+
ext = format.lower()
|
437 |
+
else:
|
438 |
+
ext = str(filepath).split(".")[-1].lower()
|
439 |
+
|
440 |
+
if bits_per_sample not in (None, 8, 16, 24, 32, 64):
|
441 |
+
raise ValueError("Invalid bits_per_sample.")
|
442 |
+
if bits_per_sample == 24:
|
443 |
+
warnings.warn(
|
444 |
+
"Saving audio with 24 bits per sample might warp samples near -1. "
|
445 |
+
"Using 16 bits per sample might be able to avoid this."
|
446 |
+
)
|
447 |
+
subtype = _get_subtype(src.dtype, ext, encoding, bits_per_sample)
|
448 |
+
|
449 |
+
# sph is a extension used in TED-LIUM but soundfile does not recognize it as NIST format,
|
450 |
+
# so we extend the extensions manually here
|
451 |
+
if ext in ["nis", "nist", "sph"] and format is None:
|
452 |
+
format = "NIST"
|
453 |
+
|
454 |
+
if channels_first:
|
455 |
+
src = src.t()
|
456 |
+
|
457 |
+
soundfile.write(file=filepath, data=src, samplerate=sample_rate, subtype=subtype, format=format)
|
MLPY/Lib/site-packages/torchaudio/_backend/sox.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import BinaryIO, Optional, Tuple, Union
|
3 |
+
|
4 |
+
import torch
|
5 |
+
import torchaudio
|
6 |
+
|
7 |
+
from .backend import Backend
|
8 |
+
from .common import AudioMetaData
|
9 |
+
|
10 |
+
sox_ext = torchaudio._extension.lazy_import_sox_ext()
|
11 |
+
|
12 |
+
|
13 |
+
class SoXBackend(Backend):
|
14 |
+
@staticmethod
|
15 |
+
def info(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], buffer_size: int = 4096) -> AudioMetaData:
|
16 |
+
if hasattr(uri, "read"):
|
17 |
+
raise ValueError(
|
18 |
+
"SoX backend does not support reading from file-like objects. ",
|
19 |
+
"Please use an alternative backend that does support reading from file-like objects, e.g. FFmpeg.",
|
20 |
+
)
|
21 |
+
else:
|
22 |
+
sinfo = sox_ext.get_info(uri, format)
|
23 |
+
if sinfo:
|
24 |
+
return AudioMetaData(*sinfo)
|
25 |
+
else:
|
26 |
+
raise RuntimeError(f"Failed to fetch metadata for {uri}.")
|
27 |
+
|
28 |
+
@staticmethod
|
29 |
+
def load(
|
30 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
31 |
+
frame_offset: int = 0,
|
32 |
+
num_frames: int = -1,
|
33 |
+
normalize: bool = True,
|
34 |
+
channels_first: bool = True,
|
35 |
+
format: Optional[str] = None,
|
36 |
+
buffer_size: int = 4096,
|
37 |
+
) -> Tuple[torch.Tensor, int]:
|
38 |
+
if hasattr(uri, "read"):
|
39 |
+
raise ValueError(
|
40 |
+
"SoX backend does not support loading from file-like objects. ",
|
41 |
+
"Please use an alternative backend that does support loading from file-like objects, e.g. FFmpeg.",
|
42 |
+
)
|
43 |
+
else:
|
44 |
+
ret = sox_ext.load_audio_file(uri, frame_offset, num_frames, normalize, channels_first, format)
|
45 |
+
if not ret:
|
46 |
+
raise RuntimeError(f"Failed to load audio from {uri}.")
|
47 |
+
return ret
|
48 |
+
|
49 |
+
@staticmethod
|
50 |
+
def save(
|
51 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
52 |
+
src: torch.Tensor,
|
53 |
+
sample_rate: int,
|
54 |
+
channels_first: bool = True,
|
55 |
+
format: Optional[str] = None,
|
56 |
+
encoding: Optional[str] = None,
|
57 |
+
bits_per_sample: Optional[int] = None,
|
58 |
+
buffer_size: int = 4096,
|
59 |
+
compression: Optional[Union[torchaudio.io.CodecConfig, float, int]] = None,
|
60 |
+
) -> None:
|
61 |
+
if not isinstance(compression, (float, int, type(None))):
|
62 |
+
raise ValueError(
|
63 |
+
"SoX backend expects non-`None` value for argument `compression` to be of ",
|
64 |
+
f"type `float` or `int`, but received value of type {type(compression)}",
|
65 |
+
)
|
66 |
+
if hasattr(uri, "write"):
|
67 |
+
raise ValueError(
|
68 |
+
"SoX backend does not support writing to file-like objects. ",
|
69 |
+
"Please use an alternative backend that does support writing to file-like objects, e.g. FFmpeg.",
|
70 |
+
)
|
71 |
+
else:
|
72 |
+
sox_ext.save_audio_file(
|
73 |
+
uri,
|
74 |
+
src,
|
75 |
+
sample_rate,
|
76 |
+
channels_first,
|
77 |
+
compression,
|
78 |
+
format,
|
79 |
+
encoding,
|
80 |
+
bits_per_sample,
|
81 |
+
)
|
82 |
+
|
83 |
+
@staticmethod
|
84 |
+
def can_decode(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str]) -> bool:
|
85 |
+
# i.e. not a file-like object.
|
86 |
+
return not hasattr(uri, "read")
|
87 |
+
|
88 |
+
@staticmethod
|
89 |
+
def can_encode(uri: Union[BinaryIO, str, os.PathLike], format: Optional[str]) -> bool:
|
90 |
+
# i.e. not a file-like object.
|
91 |
+
return not hasattr(uri, "write")
|
MLPY/Lib/site-packages/torchaudio/_backend/utils.py
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from functools import lru_cache
|
3 |
+
from typing import BinaryIO, Dict, Optional, Tuple, Type, Union
|
4 |
+
|
5 |
+
import torch
|
6 |
+
|
7 |
+
from torchaudio._extension import lazy_import_sox_ext
|
8 |
+
from torchaudio.io import CodecConfig
|
9 |
+
from torio._extension import lazy_import_ffmpeg_ext
|
10 |
+
|
11 |
+
from . import soundfile_backend
|
12 |
+
|
13 |
+
from .backend import Backend
|
14 |
+
from .common import AudioMetaData
|
15 |
+
from .ffmpeg import FFmpegBackend
|
16 |
+
from .soundfile import SoundfileBackend
|
17 |
+
from .sox import SoXBackend
|
18 |
+
|
19 |
+
|
20 |
+
@lru_cache(None)
|
21 |
+
def get_available_backends() -> Dict[str, Type[Backend]]:
|
22 |
+
backend_specs: Dict[str, Type[Backend]] = {}
|
23 |
+
if lazy_import_ffmpeg_ext().is_available():
|
24 |
+
backend_specs["ffmpeg"] = FFmpegBackend
|
25 |
+
if lazy_import_sox_ext().is_available():
|
26 |
+
backend_specs["sox"] = SoXBackend
|
27 |
+
if soundfile_backend._IS_SOUNDFILE_AVAILABLE:
|
28 |
+
backend_specs["soundfile"] = SoundfileBackend
|
29 |
+
return backend_specs
|
30 |
+
|
31 |
+
|
32 |
+
def get_backend(backend_name, backends) -> Backend:
|
33 |
+
if backend := backends.get(backend_name):
|
34 |
+
return backend
|
35 |
+
else:
|
36 |
+
raise ValueError(
|
37 |
+
f"Unsupported backend '{backend_name}' specified; ",
|
38 |
+
f"please select one of {list(backends.keys())} instead.",
|
39 |
+
)
|
40 |
+
|
41 |
+
|
42 |
+
def get_info_func():
|
43 |
+
backends = get_available_backends()
|
44 |
+
|
45 |
+
def dispatcher(
|
46 |
+
uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], backend_name: Optional[str]
|
47 |
+
) -> Backend:
|
48 |
+
if backend_name is not None:
|
49 |
+
return get_backend(backend_name, backends)
|
50 |
+
|
51 |
+
for backend in backends.values():
|
52 |
+
if backend.can_decode(uri, format):
|
53 |
+
return backend
|
54 |
+
raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
|
55 |
+
|
56 |
+
def info(
|
57 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
58 |
+
format: Optional[str] = None,
|
59 |
+
buffer_size: int = 4096,
|
60 |
+
backend: Optional[str] = None,
|
61 |
+
) -> AudioMetaData:
|
62 |
+
"""Get signal information of an audio file.
|
63 |
+
|
64 |
+
Note:
|
65 |
+
When the input type is file-like object, this function cannot
|
66 |
+
get the correct length (``num_samples``) for certain formats,
|
67 |
+
such as ``vorbis``.
|
68 |
+
In this case, the value of ``num_samples`` is ``0``.
|
69 |
+
|
70 |
+
Args:
|
71 |
+
uri (path-like object or file-like object):
|
72 |
+
Source of audio data. The following types are accepted:
|
73 |
+
|
74 |
+
* ``path-like``: File path or URL.
|
75 |
+
* ``file-like``: Object with ``read(size: int) -> bytes`` method,
|
76 |
+
which returns byte string of at most ``size`` length.
|
77 |
+
|
78 |
+
format (str or None, optional):
|
79 |
+
If not ``None``, interpreted as hint that may allow backend to override the detected format.
|
80 |
+
(Default: ``None``)
|
81 |
+
|
82 |
+
buffer_size (int, optional):
|
83 |
+
Size of buffer to use when processing file-like objects, in bytes. (Default: ``4096``)
|
84 |
+
|
85 |
+
backend (str or None, optional):
|
86 |
+
I/O backend to use.
|
87 |
+
If ``None``, function selects backend given input and available backends.
|
88 |
+
Otherwise, must be one of [``"ffmpeg"``, ``"sox"``, ``"soundfile"``],
|
89 |
+
with the corresponding backend available.
|
90 |
+
(Default: ``None``)
|
91 |
+
|
92 |
+
.. seealso::
|
93 |
+
:ref:`backend`
|
94 |
+
|
95 |
+
Returns:
|
96 |
+
AudioMetaData
|
97 |
+
"""
|
98 |
+
backend = dispatcher(uri, format, backend)
|
99 |
+
return backend.info(uri, format, buffer_size)
|
100 |
+
|
101 |
+
return info
|
102 |
+
|
103 |
+
|
104 |
+
def get_load_func():
|
105 |
+
backends = get_available_backends()
|
106 |
+
|
107 |
+
def dispatcher(
|
108 |
+
uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], backend_name: Optional[str]
|
109 |
+
) -> Backend:
|
110 |
+
if backend_name is not None:
|
111 |
+
return get_backend(backend_name, backends)
|
112 |
+
|
113 |
+
for backend in backends.values():
|
114 |
+
if backend.can_decode(uri, format):
|
115 |
+
return backend
|
116 |
+
raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
|
117 |
+
|
118 |
+
def load(
|
119 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
120 |
+
frame_offset: int = 0,
|
121 |
+
num_frames: int = -1,
|
122 |
+
normalize: bool = True,
|
123 |
+
channels_first: bool = True,
|
124 |
+
format: Optional[str] = None,
|
125 |
+
buffer_size: int = 4096,
|
126 |
+
backend: Optional[str] = None,
|
127 |
+
) -> Tuple[torch.Tensor, int]:
|
128 |
+
"""Load audio data from source.
|
129 |
+
|
130 |
+
By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with
|
131 |
+
``float32`` dtype, and the shape of `[channel, time]`.
|
132 |
+
|
133 |
+
Note:
|
134 |
+
The formats this function can handle depend on the availability of backends.
|
135 |
+
Please use the following functions to fetch the supported formats.
|
136 |
+
|
137 |
+
- FFmpeg: :py:func:`torchaudio.utils.ffmpeg_utils.get_audio_decoders`
|
138 |
+
- Sox: :py:func:`torchaudio.utils.sox_utils.list_read_formats`
|
139 |
+
- SoundFile: Refer to `the official document <https://pysoundfile.readthedocs.io/>`__.
|
140 |
+
|
141 |
+
.. warning::
|
142 |
+
|
143 |
+
``normalize`` argument does not perform volume normalization.
|
144 |
+
It only converts the sample type to `torch.float32` from the native sample
|
145 |
+
type.
|
146 |
+
|
147 |
+
When the input format is WAV with integer type, such as 32-bit signed integer, 16-bit
|
148 |
+
signed integer, 24-bit signed integer, and 8-bit unsigned integer, by providing ``normalize=False``,
|
149 |
+
this function can return integer Tensor, where the samples are expressed within the whole range
|
150 |
+
of the corresponding dtype, that is, ``int32`` tensor for 32-bit signed PCM,
|
151 |
+
``int16`` for 16-bit signed PCM and ``uint8`` for 8-bit unsigned PCM. Since torch does not
|
152 |
+
support ``int24`` dtype, 24-bit signed PCM are converted to ``int32`` tensors.
|
153 |
+
|
154 |
+
``normalize`` argument has no effect on 32-bit floating-point WAV and other formats, such as
|
155 |
+
``flac`` and ``mp3``.
|
156 |
+
|
157 |
+
For these formats, this function always returns ``float32`` Tensor with values.
|
158 |
+
|
159 |
+
|
160 |
+
Args:
|
161 |
+
uri (path-like object or file-like object):
|
162 |
+
Source of audio data.
|
163 |
+
frame_offset (int, optional):
|
164 |
+
Number of frames to skip before start reading data.
|
165 |
+
num_frames (int, optional):
|
166 |
+
Maximum number of frames to read. ``-1`` reads all the remaining samples,
|
167 |
+
starting from ``frame_offset``.
|
168 |
+
This function may return the less number of frames if there is not enough
|
169 |
+
frames in the given file.
|
170 |
+
normalize (bool, optional):
|
171 |
+
When ``True``, this function converts the native sample type to ``float32``.
|
172 |
+
Default: ``True``.
|
173 |
+
|
174 |
+
If input file is integer WAV, giving ``False`` will change the resulting Tensor type to
|
175 |
+
integer type.
|
176 |
+
This argument has no effect for formats other than integer WAV type.
|
177 |
+
|
178 |
+
channels_first (bool, optional):
|
179 |
+
When True, the returned Tensor has dimension `[channel, time]`.
|
180 |
+
Otherwise, the returned Tensor's dimension is `[time, channel]`.
|
181 |
+
|
182 |
+
format (str or None, optional):
|
183 |
+
If not ``None``, interpreted as hint that may allow backend to override the detected format.
|
184 |
+
(Default: ``None``)
|
185 |
+
|
186 |
+
buffer_size (int, optional):
|
187 |
+
Size of buffer to use when processing file-like objects, in bytes. (Default: ``4096``)
|
188 |
+
|
189 |
+
backend (str or None, optional):
|
190 |
+
I/O backend to use.
|
191 |
+
If ``None``, function selects backend given input and available backends.
|
192 |
+
Otherwise, must be one of [``"ffmpeg"``, ``"sox"``, ``"soundfile"``],
|
193 |
+
with the corresponding backend being available. (Default: ``None``)
|
194 |
+
|
195 |
+
.. seealso::
|
196 |
+
:ref:`backend`
|
197 |
+
|
198 |
+
Returns:
|
199 |
+
(torch.Tensor, int): Resulting Tensor and sample rate.
|
200 |
+
If the input file has integer wav format and normalization is off, then it has
|
201 |
+
integer type, else ``float32`` type. If ``channels_first=True``, it has
|
202 |
+
`[channel, time]` else `[time, channel]`.
|
203 |
+
"""
|
204 |
+
backend = dispatcher(uri, format, backend)
|
205 |
+
return backend.load(uri, frame_offset, num_frames, normalize, channels_first, format, buffer_size)
|
206 |
+
|
207 |
+
return load
|
208 |
+
|
209 |
+
|
210 |
+
def get_save_func():
|
211 |
+
backends = get_available_backends()
|
212 |
+
|
213 |
+
def dispatcher(
|
214 |
+
uri: Union[BinaryIO, str, os.PathLike], format: Optional[str], backend_name: Optional[str]
|
215 |
+
) -> Backend:
|
216 |
+
if backend_name is not None:
|
217 |
+
return get_backend(backend_name, backends)
|
218 |
+
|
219 |
+
for backend in backends.values():
|
220 |
+
if backend.can_encode(uri, format):
|
221 |
+
return backend
|
222 |
+
raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
|
223 |
+
|
224 |
+
def save(
|
225 |
+
uri: Union[BinaryIO, str, os.PathLike],
|
226 |
+
src: torch.Tensor,
|
227 |
+
sample_rate: int,
|
228 |
+
channels_first: bool = True,
|
229 |
+
format: Optional[str] = None,
|
230 |
+
encoding: Optional[str] = None,
|
231 |
+
bits_per_sample: Optional[int] = None,
|
232 |
+
buffer_size: int = 4096,
|
233 |
+
backend: Optional[str] = None,
|
234 |
+
compression: Optional[Union[CodecConfig, float, int]] = None,
|
235 |
+
):
|
236 |
+
"""Save audio data to file.
|
237 |
+
|
238 |
+
Note:
|
239 |
+
The formats this function can handle depend on the availability of backends.
|
240 |
+
Please use the following functions to fetch the supported formats.
|
241 |
+
|
242 |
+
- FFmpeg: :py:func:`torchaudio.utils.ffmpeg_utils.get_audio_encoders`
|
243 |
+
- Sox: :py:func:`torchaudio.utils.sox_utils.list_write_formats`
|
244 |
+
- SoundFile: Refer to `the official document <https://pysoundfile.readthedocs.io/>`__.
|
245 |
+
|
246 |
+
Args:
|
247 |
+
uri (str or pathlib.Path): Path to audio file.
|
248 |
+
src (torch.Tensor): Audio data to save. must be 2D tensor.
|
249 |
+
sample_rate (int): sampling rate
|
250 |
+
channels_first (bool, optional): If ``True``, the given tensor is interpreted as `[channel, time]`,
|
251 |
+
otherwise `[time, channel]`.
|
252 |
+
format (str or None, optional): Override the audio format.
|
253 |
+
When ``uri`` argument is path-like object, audio format is
|
254 |
+
inferred from file extension. If the file extension is missing or
|
255 |
+
different, you can specify the correct format with this argument.
|
256 |
+
|
257 |
+
When ``uri`` argument is file-like object,
|
258 |
+
this argument is required.
|
259 |
+
|
260 |
+
Valid values are ``"wav"``, ``"ogg"``, and ``"flac"``.
|
261 |
+
encoding (str or None, optional): Changes the encoding for supported formats.
|
262 |
+
This argument is effective only for supported formats, i.e.
|
263 |
+
``"wav"`` and ``""flac"```. Valid values are
|
264 |
+
|
265 |
+
- ``"PCM_S"`` (signed integer Linear PCM)
|
266 |
+
- ``"PCM_U"`` (unsigned integer Linear PCM)
|
267 |
+
- ``"PCM_F"`` (floating point PCM)
|
268 |
+
- ``"ULAW"`` (mu-law)
|
269 |
+
- ``"ALAW"`` (a-law)
|
270 |
+
|
271 |
+
bits_per_sample (int or None, optional): Changes the bit depth for the
|
272 |
+
supported formats.
|
273 |
+
When ``format`` is one of ``"wav"`` and ``"flac"``,
|
274 |
+
you can change the bit depth.
|
275 |
+
Valid values are ``8``, ``16``, ``24``, ``32`` and ``64``.
|
276 |
+
|
277 |
+
buffer_size (int, optional):
|
278 |
+
Size of buffer to use when processing file-like objects, in bytes. (Default: ``4096``)
|
279 |
+
|
280 |
+
backend (str or None, optional):
|
281 |
+
I/O backend to use.
|
282 |
+
If ``None``, function selects backend given input and available backends.
|
283 |
+
Otherwise, must be one of [``"ffmpeg"``, ``"sox"``, ``"soundfile"``],
|
284 |
+
with the corresponding backend being available.
|
285 |
+
(Default: ``None``)
|
286 |
+
|
287 |
+
.. seealso::
|
288 |
+
:ref:`backend`
|
289 |
+
|
290 |
+
compression (CodecConfig, float, int, or None, optional):
|
291 |
+
Compression configuration to apply.
|
292 |
+
|
293 |
+
If the selected backend is FFmpeg, an instance of :py:class:`CodecConfig` must be provided.
|
294 |
+
|
295 |
+
Otherwise, if the selected backend is SoX, a float or int value corresponding to option ``-C`` of the
|
296 |
+
``sox`` command line interface must be provided. For instance:
|
297 |
+
|
298 |
+
``"mp3"``
|
299 |
+
Either bitrate (in ``kbps``) with quality factor, such as ``128.2``, or
|
300 |
+
VBR encoding with quality factor such as ``-4.2``. Default: ``-4.5``.
|
301 |
+
|
302 |
+
``"flac"``
|
303 |
+
Whole number from ``0`` to ``8``. ``8`` is default and highest compression.
|
304 |
+
|
305 |
+
``"ogg"``, ``"vorbis"``
|
306 |
+
Number from ``-1`` to ``10``; ``-1`` is the highest compression
|
307 |
+
and lowest quality. Default: ``3``.
|
308 |
+
|
309 |
+
Refer to http://sox.sourceforge.net/soxformat.html for more details.
|
310 |
+
|
311 |
+
"""
|
312 |
+
backend = dispatcher(uri, format, backend)
|
313 |
+
return backend.save(
|
314 |
+
uri, src, sample_rate, channels_first, format, encoding, bits_per_sample, buffer_size, compression
|
315 |
+
)
|
316 |
+
|
317 |
+
return save
|
MLPY/Lib/site-packages/torchaudio/_extension/__init__.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
+
|
5 |
+
from torchaudio._internal.module_utils import fail_with_message, is_module_available, no_op
|
6 |
+
|
7 |
+
from .utils import _check_cuda_version, _init_dll_path, _init_sox, _LazyImporter, _load_lib
|
8 |
+
|
9 |
+
_LG = logging.getLogger(__name__)
|
10 |
+
|
11 |
+
|
12 |
+
# Note:
|
13 |
+
# `_check_cuda_version` is not meant to be used by regular users.
|
14 |
+
# Builder uses it for debugging purpose, so we export it.
|
15 |
+
# https://github.com/pytorch/builder/blob/e2e4542b8eb0bdf491214451a1a4128bd606cce2/test/smoke_test/smoke_test.py#L80
|
16 |
+
__all__ = [
|
17 |
+
"_check_cuda_version",
|
18 |
+
"_IS_TORCHAUDIO_EXT_AVAILABLE",
|
19 |
+
"_IS_RIR_AVAILABLE",
|
20 |
+
"lazy_import_sox_ext",
|
21 |
+
]
|
22 |
+
|
23 |
+
|
24 |
+
if os.name == "nt" and (3, 8) <= sys.version_info < (3, 9):
|
25 |
+
_init_dll_path()
|
26 |
+
|
27 |
+
|
28 |
+
# When the extension module is built, we initialize it.
|
29 |
+
# In case of an error, we do not catch the failure as it suggests there is something
|
30 |
+
# wrong with the installation.
|
31 |
+
_IS_TORCHAUDIO_EXT_AVAILABLE = is_module_available("torchaudio.lib._torchaudio")
|
32 |
+
# RIR features are implemented in _torchaudio extension, but they can be individually
|
33 |
+
# turned on/off at build time. Available means that _torchaudio is loaded properly, and
|
34 |
+
# RIR features are found there.
|
35 |
+
_IS_RIR_AVAILABLE = False
|
36 |
+
_IS_ALIGN_AVAILABLE = False
|
37 |
+
if _IS_TORCHAUDIO_EXT_AVAILABLE:
|
38 |
+
_load_lib("libtorchaudio")
|
39 |
+
|
40 |
+
import torchaudio.lib._torchaudio # noqa
|
41 |
+
|
42 |
+
_check_cuda_version()
|
43 |
+
_IS_RIR_AVAILABLE = torchaudio.lib._torchaudio.is_rir_available()
|
44 |
+
_IS_ALIGN_AVAILABLE = torchaudio.lib._torchaudio.is_align_available()
|
45 |
+
|
46 |
+
|
47 |
+
_SOX_EXT = None
|
48 |
+
|
49 |
+
|
50 |
+
def lazy_import_sox_ext():
|
51 |
+
"""Load SoX integration based on availability in lazy manner"""
|
52 |
+
|
53 |
+
global _SOX_EXT
|
54 |
+
if _SOX_EXT is None:
|
55 |
+
_SOX_EXT = _LazyImporter("_torchaudio_sox", _init_sox)
|
56 |
+
return _SOX_EXT
|
57 |
+
|
58 |
+
|
59 |
+
fail_if_no_rir = (
|
60 |
+
no_op
|
61 |
+
if _IS_RIR_AVAILABLE
|
62 |
+
else fail_with_message(
|
63 |
+
"requires RIR extension, but TorchAudio is not compiled with it. Please build TorchAudio with RIR support."
|
64 |
+
)
|
65 |
+
)
|
66 |
+
|
67 |
+
fail_if_no_align = (
|
68 |
+
no_op
|
69 |
+
if _IS_ALIGN_AVAILABLE
|
70 |
+
else fail_with_message(
|
71 |
+
"Requires alignment extension, but TorchAudio is not compiled with it. \
|
72 |
+
Please build TorchAudio with alignment support."
|
73 |
+
)
|
74 |
+
)
|
MLPY/Lib/site-packages/torchaudio/_extension/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (1.5 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_extension/__pycache__/utils.cpython-39.pyc
ADDED
Binary file (5.95 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_extension/utils.py
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Module to implement logics used for initializing extensions.
|
2 |
+
|
3 |
+
The implementations here should be stateless.
|
4 |
+
They should not depend on external state.
|
5 |
+
Anything that depends on external state should happen in __init__.py
|
6 |
+
"""
|
7 |
+
import importlib
|
8 |
+
import logging
|
9 |
+
import os
|
10 |
+
import types
|
11 |
+
from pathlib import Path
|
12 |
+
|
13 |
+
import torch
|
14 |
+
from torchaudio._internal.module_utils import eval_env
|
15 |
+
|
16 |
+
_LG = logging.getLogger(__name__)
|
17 |
+
_LIB_DIR = Path(__file__).parent.parent / "lib"
|
18 |
+
|
19 |
+
|
20 |
+
def _get_lib_path(lib: str):
|
21 |
+
suffix = "pyd" if os.name == "nt" else "so"
|
22 |
+
path = _LIB_DIR / f"{lib}.{suffix}"
|
23 |
+
return path
|
24 |
+
|
25 |
+
|
26 |
+
def _load_lib(lib: str) -> bool:
|
27 |
+
"""Load extension module
|
28 |
+
|
29 |
+
Note:
|
30 |
+
In case `torchaudio` is deployed with `pex` format, the library file
|
31 |
+
is not in a standard location.
|
32 |
+
In this case, we expect that `libtorchaudio` is available somewhere
|
33 |
+
in the search path of dynamic loading mechanism, so that importing
|
34 |
+
`_torchaudio` will have library loader find and load `libtorchaudio`.
|
35 |
+
This is the reason why the function should not raising an error when the library
|
36 |
+
file is not found.
|
37 |
+
|
38 |
+
Returns:
|
39 |
+
bool:
|
40 |
+
True if the library file is found AND the library loaded without failure.
|
41 |
+
False if the library file is not found (like in the case where torchaudio
|
42 |
+
is deployed with pex format, thus the shared library file is
|
43 |
+
in a non-standard location.).
|
44 |
+
If the library file is found but there is an issue loading the library,
|
45 |
+
(such as missing dependency) then this function raises the exception as-is.
|
46 |
+
|
47 |
+
Raises:
|
48 |
+
Exception:
|
49 |
+
If the library file is found, but there is an issue loading the library file,
|
50 |
+
(when underlying `ctype.DLL` throws an exception), this function will pass
|
51 |
+
the exception as-is, instead of catching it and returning bool.
|
52 |
+
The expected case is `OSError` thrown by `ctype.DLL` when a dynamic dependency
|
53 |
+
is not found.
|
54 |
+
This behavior was chosen because the expected failure case is not recoverable.
|
55 |
+
If a dependency is missing, then users have to install it.
|
56 |
+
"""
|
57 |
+
path = _get_lib_path(lib)
|
58 |
+
if not path.exists():
|
59 |
+
return False
|
60 |
+
torch.ops.load_library(path)
|
61 |
+
return True
|
62 |
+
|
63 |
+
|
64 |
+
def _import_sox_ext():
|
65 |
+
if os.name == "nt":
|
66 |
+
raise RuntimeError("sox extension is not supported on Windows")
|
67 |
+
if not eval_env("TORCHAUDIO_USE_SOX", True):
|
68 |
+
raise RuntimeError("sox extension is disabled. (TORCHAUDIO_USE_SOX=0)")
|
69 |
+
|
70 |
+
ext = "torchaudio.lib._torchaudio_sox"
|
71 |
+
|
72 |
+
if not importlib.util.find_spec(ext):
|
73 |
+
raise RuntimeError(
|
74 |
+
# fmt: off
|
75 |
+
"TorchAudio is not built with sox extension. "
|
76 |
+
"Please build TorchAudio with libsox support. (BUILD_SOX=1)"
|
77 |
+
# fmt: on
|
78 |
+
)
|
79 |
+
|
80 |
+
_load_lib("libtorchaudio_sox")
|
81 |
+
return importlib.import_module(ext)
|
82 |
+
|
83 |
+
|
84 |
+
def _init_sox():
|
85 |
+
ext = _import_sox_ext()
|
86 |
+
ext.set_verbosity(0)
|
87 |
+
|
88 |
+
import atexit
|
89 |
+
|
90 |
+
torch.ops.torchaudio_sox.initialize_sox_effects()
|
91 |
+
atexit.register(torch.ops.torchaudio_sox.shutdown_sox_effects)
|
92 |
+
|
93 |
+
# Bundle functions registered with TORCH_LIBRARY into extension
|
94 |
+
# so that they can also be accessed in the same (lazy) manner
|
95 |
+
# from the extension.
|
96 |
+
keys = [
|
97 |
+
"get_info",
|
98 |
+
"load_audio_file",
|
99 |
+
"save_audio_file",
|
100 |
+
"apply_effects_tensor",
|
101 |
+
"apply_effects_file",
|
102 |
+
]
|
103 |
+
for key in keys:
|
104 |
+
setattr(ext, key, getattr(torch.ops.torchaudio_sox, key))
|
105 |
+
|
106 |
+
return ext
|
107 |
+
|
108 |
+
|
109 |
+
class _LazyImporter(types.ModuleType):
|
110 |
+
"""Lazily import module/extension."""
|
111 |
+
|
112 |
+
def __init__(self, name, import_func):
|
113 |
+
super().__init__(name)
|
114 |
+
self.import_func = import_func
|
115 |
+
self.module = None
|
116 |
+
|
117 |
+
# Note:
|
118 |
+
# Python caches what was retrieved with `__getattr__`, so this method will not be
|
119 |
+
# called again for the same item.
|
120 |
+
def __getattr__(self, item):
|
121 |
+
self._import_once()
|
122 |
+
return getattr(self.module, item)
|
123 |
+
|
124 |
+
def __repr__(self):
|
125 |
+
if self.module is None:
|
126 |
+
return f"<module '{self.__module__}.{self.__class__.__name__}(\"{self.name}\")'>"
|
127 |
+
return repr(self.module)
|
128 |
+
|
129 |
+
def __dir__(self):
|
130 |
+
self._import_once()
|
131 |
+
return dir(self.module)
|
132 |
+
|
133 |
+
def _import_once(self):
|
134 |
+
if self.module is None:
|
135 |
+
self.module = self.import_func()
|
136 |
+
# Note:
|
137 |
+
# By attaching the module attributes to self,
|
138 |
+
# module attributes are directly accessible.
|
139 |
+
# This allows to avoid calling __getattr__ for every attribute access.
|
140 |
+
self.__dict__.update(self.module.__dict__)
|
141 |
+
|
142 |
+
def is_available(self):
|
143 |
+
try:
|
144 |
+
self._import_once()
|
145 |
+
except Exception:
|
146 |
+
return False
|
147 |
+
return True
|
148 |
+
|
149 |
+
|
150 |
+
def _init_dll_path():
|
151 |
+
# On Windows Python-3.8+ has `os.add_dll_directory` call,
|
152 |
+
# which is called to configure dll search path.
|
153 |
+
# To find cuda related dlls we need to make sure the
|
154 |
+
# conda environment/bin path is configured Please take a look:
|
155 |
+
# https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python
|
156 |
+
# Please note: if some path can't be added using add_dll_directory we simply ignore this path
|
157 |
+
for path in os.environ.get("PATH", "").split(";"):
|
158 |
+
if os.path.exists(path):
|
159 |
+
try:
|
160 |
+
os.add_dll_directory(path)
|
161 |
+
except Exception:
|
162 |
+
pass
|
163 |
+
|
164 |
+
|
165 |
+
def _check_cuda_version():
|
166 |
+
import torchaudio.lib._torchaudio
|
167 |
+
|
168 |
+
version = torchaudio.lib._torchaudio.cuda_version()
|
169 |
+
if version is not None and torch.version.cuda is not None:
|
170 |
+
version_str = str(version)
|
171 |
+
ta_version = f"{version_str[:-3]}.{version_str[-2]}"
|
172 |
+
t_version = torch.version.cuda.split(".")
|
173 |
+
t_version = f"{t_version[0]}.{t_version[1]}"
|
174 |
+
if ta_version != t_version:
|
175 |
+
raise RuntimeError(
|
176 |
+
"Detected that PyTorch and TorchAudio were compiled with different CUDA versions. "
|
177 |
+
f"PyTorch has CUDA version {t_version} whereas TorchAudio has CUDA version {ta_version}. "
|
178 |
+
"Please install the TorchAudio version that matches your PyTorch version."
|
179 |
+
)
|
180 |
+
return version
|
MLPY/Lib/site-packages/torchaudio/_internal/__init__.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
try:
|
2 |
+
from .fb import download_url_to_file, load_state_dict_from_url
|
3 |
+
except ImportError:
|
4 |
+
from torch.hub import download_url_to_file, load_state_dict_from_url
|
5 |
+
|
6 |
+
|
7 |
+
__all__ = [
|
8 |
+
"load_state_dict_from_url",
|
9 |
+
"download_url_to_file",
|
10 |
+
]
|
MLPY/Lib/site-packages/torchaudio/_internal/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (347 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/_internal/__pycache__/module_utils.cpython-39.pyc
ADDED
Binary file (4.5 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/_internal/module_utils.py
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import importlib.util
|
2 |
+
import os
|
3 |
+
import warnings
|
4 |
+
from functools import wraps
|
5 |
+
from typing import Optional
|
6 |
+
|
7 |
+
|
8 |
+
def eval_env(var, default):
|
9 |
+
"""Check if environment varable has True-y value"""
|
10 |
+
if var not in os.environ:
|
11 |
+
return default
|
12 |
+
|
13 |
+
val = os.environ.get(var, "0")
|
14 |
+
trues = ["1", "true", "TRUE", "on", "ON", "yes", "YES"]
|
15 |
+
falses = ["0", "false", "FALSE", "off", "OFF", "no", "NO"]
|
16 |
+
if val in trues:
|
17 |
+
return True
|
18 |
+
if val not in falses:
|
19 |
+
# fmt: off
|
20 |
+
raise RuntimeError(
|
21 |
+
f"Unexpected environment variable value `{var}={val}`. "
|
22 |
+
f"Expected one of {trues + falses}")
|
23 |
+
# fmt: on
|
24 |
+
return False
|
25 |
+
|
26 |
+
|
27 |
+
def is_module_available(*modules: str) -> bool:
|
28 |
+
r"""Returns if a top-level module with :attr:`name` exists *without**
|
29 |
+
importing it. This is generally safer than try-catch block around a
|
30 |
+
`import X`. It avoids third party libraries breaking assumptions of some of
|
31 |
+
our tests, e.g., setting multiprocessing start method when imported
|
32 |
+
(see librosa/#747, torchvision/#544).
|
33 |
+
"""
|
34 |
+
return all(importlib.util.find_spec(m) is not None for m in modules)
|
35 |
+
|
36 |
+
|
37 |
+
def requires_module(*modules: str):
|
38 |
+
"""Decorate function to give error message if invoked without required optional modules.
|
39 |
+
|
40 |
+
This decorator is to give better error message to users rather
|
41 |
+
than raising ``NameError: name 'module' is not defined`` at random places.
|
42 |
+
"""
|
43 |
+
missing = [m for m in modules if not is_module_available(m)]
|
44 |
+
|
45 |
+
if not missing:
|
46 |
+
# fall through. If all the modules are available, no need to decorate
|
47 |
+
def decorator(func):
|
48 |
+
return func
|
49 |
+
|
50 |
+
else:
|
51 |
+
req = f"module: {missing[0]}" if len(missing) == 1 else f"modules: {missing}"
|
52 |
+
|
53 |
+
def decorator(func):
|
54 |
+
@wraps(func)
|
55 |
+
def wrapped(*args, **kwargs):
|
56 |
+
raise RuntimeError(f"{func.__module__}.{func.__name__} requires {req}")
|
57 |
+
|
58 |
+
return wrapped
|
59 |
+
|
60 |
+
return decorator
|
61 |
+
|
62 |
+
|
63 |
+
def deprecated(direction: str, version: Optional[str] = None, remove: bool = False):
|
64 |
+
"""Decorator to add deprecation message
|
65 |
+
|
66 |
+
Args:
|
67 |
+
direction (str): Migration steps to be given to users.
|
68 |
+
version (str or int): The version when the object will be removed
|
69 |
+
remove (bool): If enabled, append future removal message.
|
70 |
+
"""
|
71 |
+
|
72 |
+
def decorator(func):
|
73 |
+
@wraps(func)
|
74 |
+
def wrapped(*args, **kwargs):
|
75 |
+
message = f"{func.__module__}.{func.__name__} has been deprecated. {direction}"
|
76 |
+
if remove:
|
77 |
+
message += f' It will be removed from {"future" if version is None else version} release. '
|
78 |
+
warnings.warn(message, stacklevel=2)
|
79 |
+
return func(*args, **kwargs)
|
80 |
+
|
81 |
+
message = "This function has been deprecated. "
|
82 |
+
if remove:
|
83 |
+
message += f'It will be removed from {"future" if version is None else version} release. '
|
84 |
+
|
85 |
+
wrapped.__doc__ = f"""DEPRECATED: {func.__doc__}
|
86 |
+
|
87 |
+
.. warning::
|
88 |
+
|
89 |
+
{message}
|
90 |
+
{direction}
|
91 |
+
"""
|
92 |
+
|
93 |
+
return wrapped
|
94 |
+
|
95 |
+
return decorator
|
96 |
+
|
97 |
+
|
98 |
+
def fail_with_message(message):
|
99 |
+
"""Generate decorator to give users message about missing TorchAudio extension."""
|
100 |
+
|
101 |
+
def decorator(func):
|
102 |
+
@wraps(func)
|
103 |
+
def wrapped(*args, **kwargs):
|
104 |
+
raise RuntimeError(f"{func.__module__}.{func.__name__} {message}")
|
105 |
+
|
106 |
+
return wrapped
|
107 |
+
|
108 |
+
return decorator
|
109 |
+
|
110 |
+
|
111 |
+
def no_op(func):
|
112 |
+
"""Op-op decorator. Used in place of fail_with_message when a functionality that requires extension works fine."""
|
113 |
+
return func
|
MLPY/Lib/site-packages/torchaudio/backend/__init__.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# NOTE:
|
2 |
+
# The entire `torchaudio.backend` module is deprecated.
|
3 |
+
# New things should be added to `torchaudio._backend`.
|
4 |
+
# Only things related to backward compatibility should be placed here.
|
5 |
+
|
6 |
+
from . import common, no_backend, soundfile_backend, sox_io_backend # noqa
|
7 |
+
|
8 |
+
__all__ = []
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (275 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/_no_backend.cpython-39.pyc
ADDED
Binary file (1.11 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/_sox_io_backend.cpython-39.pyc
ADDED
Binary file (11.3 kB). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/common.cpython-39.pyc
ADDED
Binary file (618 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/no_backend.cpython-39.pyc
ADDED
Binary file (677 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/soundfile_backend.cpython-39.pyc
ADDED
Binary file (704 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/__pycache__/sox_io_backend.cpython-39.pyc
ADDED
Binary file (685 Bytes). View file
|
|
MLPY/Lib/site-packages/torchaudio/backend/_no_backend.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
from typing import Callable, Optional, Tuple, Union
|
3 |
+
|
4 |
+
from torch import Tensor
|
5 |
+
from torchaudio import AudioMetaData
|
6 |
+
|
7 |
+
|
8 |
+
def load(
|
9 |
+
filepath: Union[str, Path],
|
10 |
+
out: Optional[Tensor] = None,
|
11 |
+
normalization: Union[bool, float, Callable] = True,
|
12 |
+
channels_first: bool = True,
|
13 |
+
num_frames: int = 0,
|
14 |
+
offset: int = 0,
|
15 |
+
filetype: Optional[str] = None,
|
16 |
+
) -> Tuple[Tensor, int]:
|
17 |
+
raise RuntimeError("No audio I/O backend is available.")
|
18 |
+
|
19 |
+
|
20 |
+
def save(filepath: str, src: Tensor, sample_rate: int, precision: int = 16, channels_first: bool = True) -> None:
|
21 |
+
raise RuntimeError("No audio I/O backend is available.")
|
22 |
+
|
23 |
+
|
24 |
+
def info(filepath: str) -> AudioMetaData:
|
25 |
+
raise RuntimeError("No audio I/O backend is available.")
|
MLPY/Lib/site-packages/torchaudio/backend/_sox_io_backend.py
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from typing import Optional, Tuple
|
3 |
+
|
4 |
+
import torch
|
5 |
+
import torchaudio
|
6 |
+
from torchaudio import AudioMetaData
|
7 |
+
|
8 |
+
sox_ext = torchaudio._extension.lazy_import_sox_ext()
|
9 |
+
|
10 |
+
|
11 |
+
def info(
|
12 |
+
filepath: str,
|
13 |
+
format: Optional[str] = None,
|
14 |
+
) -> AudioMetaData:
|
15 |
+
"""Get signal information of an audio file.
|
16 |
+
|
17 |
+
Args:
|
18 |
+
filepath (str):
|
19 |
+
Source of audio data.
|
20 |
+
|
21 |
+
format (str or None, optional):
|
22 |
+
Override the format detection with the given format.
|
23 |
+
Providing the argument might help when libsox can not infer the format
|
24 |
+
from header or extension.
|
25 |
+
|
26 |
+
Returns:
|
27 |
+
AudioMetaData: Metadata of the given audio.
|
28 |
+
"""
|
29 |
+
if not torch.jit.is_scripting():
|
30 |
+
if hasattr(filepath, "read"):
|
31 |
+
raise RuntimeError("sox_io backend does not support file-like object.")
|
32 |
+
filepath = os.fspath(filepath)
|
33 |
+
sinfo = sox_ext.get_info(filepath, format)
|
34 |
+
return AudioMetaData(*sinfo)
|
35 |
+
|
36 |
+
|
37 |
+
def load(
|
38 |
+
filepath: str,
|
39 |
+
frame_offset: int = 0,
|
40 |
+
num_frames: int = -1,
|
41 |
+
normalize: bool = True,
|
42 |
+
channels_first: bool = True,
|
43 |
+
format: Optional[str] = None,
|
44 |
+
) -> Tuple[torch.Tensor, int]:
|
45 |
+
"""Load audio data from file.
|
46 |
+
|
47 |
+
Note:
|
48 |
+
This function can handle all the codecs that underlying libsox can handle,
|
49 |
+
however it is tested on the following formats;
|
50 |
+
|
51 |
+
* WAV, AMB
|
52 |
+
|
53 |
+
* 32-bit floating-point
|
54 |
+
* 32-bit signed integer
|
55 |
+
* 24-bit signed integer
|
56 |
+
* 16-bit signed integer
|
57 |
+
* 8-bit unsigned integer (WAV only)
|
58 |
+
|
59 |
+
* MP3
|
60 |
+
* FLAC
|
61 |
+
* OGG/VORBIS
|
62 |
+
* OPUS
|
63 |
+
* SPHERE
|
64 |
+
* AMR-NB
|
65 |
+
|
66 |
+
To load ``MP3``, ``FLAC``, ``OGG/VORBIS``, ``OPUS`` and other codecs ``libsox`` does not
|
67 |
+
handle natively, your installation of ``torchaudio`` has to be linked to ``libsox``
|
68 |
+
and corresponding codec libraries such as ``libmad`` or ``libmp3lame`` etc.
|
69 |
+
|
70 |
+
By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with
|
71 |
+
``float32`` dtype, and the shape of `[channel, time]`.
|
72 |
+
|
73 |
+
.. warning::
|
74 |
+
|
75 |
+
``normalize`` argument does not perform volume normalization.
|
76 |
+
It only converts the sample type to `torch.float32` from the native sample
|
77 |
+
type.
|
78 |
+
|
79 |
+
When the input format is WAV with integer type, such as 32-bit signed integer, 16-bit
|
80 |
+
signed integer, 24-bit signed integer, and 8-bit unsigned integer, by providing ``normalize=False``,
|
81 |
+
this function can return integer Tensor, where the samples are expressed within the whole range
|
82 |
+
of the corresponding dtype, that is, ``int32`` tensor for 32-bit signed PCM,
|
83 |
+
``int16`` for 16-bit signed PCM and ``uint8`` for 8-bit unsigned PCM. Since torch does not
|
84 |
+
support ``int24`` dtype, 24-bit signed PCM are converted to ``int32`` tensors.
|
85 |
+
|
86 |
+
``normalize`` argument has no effect on 32-bit floating-point WAV and other formats, such as
|
87 |
+
``flac`` and ``mp3``.
|
88 |
+
|
89 |
+
For these formats, this function always returns ``float32`` Tensor with values.
|
90 |
+
|
91 |
+
Args:
|
92 |
+
filepath (path-like object): Source of audio data.
|
93 |
+
frame_offset (int):
|
94 |
+
Number of frames to skip before start reading data.
|
95 |
+
num_frames (int, optional):
|
96 |
+
Maximum number of frames to read. ``-1`` reads all the remaining samples,
|
97 |
+
starting from ``frame_offset``.
|
98 |
+
This function may return the less number of frames if there is not enough
|
99 |
+
frames in the given file.
|
100 |
+
normalize (bool, optional):
|
101 |
+
When ``True``, this function converts the native sample type to ``float32``.
|
102 |
+
Default: ``True``.
|
103 |
+
|
104 |
+
If input file is integer WAV, giving ``False`` will change the resulting Tensor type to
|
105 |
+
integer type.
|
106 |
+
This argument has no effect for formats other than integer WAV type.
|
107 |
+
|
108 |
+
channels_first (bool, optional):
|
109 |
+
When True, the returned Tensor has dimension `[channel, time]`.
|
110 |
+
Otherwise, the returned Tensor's dimension is `[time, channel]`.
|
111 |
+
format (str or None, optional):
|
112 |
+
Override the format detection with the given format.
|
113 |
+
Providing the argument might help when libsox can not infer the format
|
114 |
+
from header or extension.
|
115 |
+
|
116 |
+
Returns:
|
117 |
+
(torch.Tensor, int): Resulting Tensor and sample rate.
|
118 |
+
If the input file has integer wav format and ``normalize=False``, then it has
|
119 |
+
integer type, else ``float32`` type. If ``channels_first=True``, it has
|
120 |
+
`[channel, time]` else `[time, channel]`.
|
121 |
+
"""
|
122 |
+
if not torch.jit.is_scripting():
|
123 |
+
if hasattr(filepath, "read"):
|
124 |
+
raise RuntimeError("sox_io backend does not support file-like object.")
|
125 |
+
filepath = os.fspath(filepath)
|
126 |
+
return sox_ext.load_audio_file(filepath, frame_offset, num_frames, normalize, channels_first, format)
|
127 |
+
|
128 |
+
|
129 |
+
def save(
|
130 |
+
filepath: str,
|
131 |
+
src: torch.Tensor,
|
132 |
+
sample_rate: int,
|
133 |
+
channels_first: bool = True,
|
134 |
+
compression: Optional[float] = None,
|
135 |
+
format: Optional[str] = None,
|
136 |
+
encoding: Optional[str] = None,
|
137 |
+
bits_per_sample: Optional[int] = None,
|
138 |
+
):
|
139 |
+
"""Save audio data to file.
|
140 |
+
|
141 |
+
Args:
|
142 |
+
filepath (path-like object): Path to save file.
|
143 |
+
src (torch.Tensor): Audio data to save. must be 2D tensor.
|
144 |
+
sample_rate (int): sampling rate
|
145 |
+
channels_first (bool, optional): If ``True``, the given tensor is interpreted as `[channel, time]`,
|
146 |
+
otherwise `[time, channel]`.
|
147 |
+
compression (float or None, optional): Used for formats other than WAV.
|
148 |
+
This corresponds to ``-C`` option of ``sox`` command.
|
149 |
+
|
150 |
+
``"mp3"``
|
151 |
+
Either bitrate (in ``kbps``) with quality factor, such as ``128.2``, or
|
152 |
+
VBR encoding with quality factor such as ``-4.2``. Default: ``-4.5``.
|
153 |
+
|
154 |
+
``"flac"``
|
155 |
+
Whole number from ``0`` to ``8``. ``8`` is default and highest compression.
|
156 |
+
|
157 |
+
``"ogg"``, ``"vorbis"``
|
158 |
+
Number from ``-1`` to ``10``; ``-1`` is the highest compression
|
159 |
+
and lowest quality. Default: ``3``.
|
160 |
+
|
161 |
+
See the detail at http://sox.sourceforge.net/soxformat.html.
|
162 |
+
format (str or None, optional): Override the audio format.
|
163 |
+
When ``filepath`` argument is path-like object, audio format is infered from
|
164 |
+
file extension. If file extension is missing or different, you can specify the
|
165 |
+
correct format with this argument.
|
166 |
+
|
167 |
+
When ``filepath`` argument is file-like object, this argument is required.
|
168 |
+
|
169 |
+
Valid values are ``"wav"``, ``"mp3"``, ``"ogg"``, ``"vorbis"``, ``"amr-nb"``,
|
170 |
+
``"amb"``, ``"flac"``, ``"sph"``, ``"gsm"``, and ``"htk"``.
|
171 |
+
|
172 |
+
encoding (str or None, optional): Changes the encoding for the supported formats.
|
173 |
+
This argument is effective only for supported formats, such as ``"wav"``, ``""amb"``
|
174 |
+
and ``"sph"``. Valid values are;
|
175 |
+
|
176 |
+
- ``"PCM_S"`` (signed integer Linear PCM)
|
177 |
+
- ``"PCM_U"`` (unsigned integer Linear PCM)
|
178 |
+
- ``"PCM_F"`` (floating point PCM)
|
179 |
+
- ``"ULAW"`` (mu-law)
|
180 |
+
- ``"ALAW"`` (a-law)
|
181 |
+
|
182 |
+
Default values
|
183 |
+
If not provided, the default value is picked based on ``format`` and ``bits_per_sample``.
|
184 |
+
|
185 |
+
``"wav"``, ``"amb"``
|
186 |
+
- | If both ``encoding`` and ``bits_per_sample`` are not provided, the ``dtype`` of the
|
187 |
+
| Tensor is used to determine the default value.
|
188 |
+
|
189 |
+
- ``"PCM_U"`` if dtype is ``uint8``
|
190 |
+
- ``"PCM_S"`` if dtype is ``int16`` or ``int32``
|
191 |
+
- ``"PCM_F"`` if dtype is ``float32``
|
192 |
+
|
193 |
+
- ``"PCM_U"`` if ``bits_per_sample=8``
|
194 |
+
- ``"PCM_S"`` otherwise
|
195 |
+
|
196 |
+
``"sph"`` format;
|
197 |
+
- the default value is ``"PCM_S"``
|
198 |
+
|
199 |
+
bits_per_sample (int or None, optional): Changes the bit depth for the supported formats.
|
200 |
+
When ``format`` is one of ``"wav"``, ``"flac"``, ``"sph"``, or ``"amb"``, you can change the
|
201 |
+
bit depth. Valid values are ``8``, ``16``, ``32`` and ``64``.
|
202 |
+
|
203 |
+
Default Value;
|
204 |
+
If not provided, the default values are picked based on ``format`` and ``"encoding"``;
|
205 |
+
|
206 |
+
``"wav"``, ``"amb"``;
|
207 |
+
- | If both ``encoding`` and ``bits_per_sample`` are not provided, the ``dtype`` of the
|
208 |
+
| Tensor is used.
|
209 |
+
|
210 |
+
- ``8`` if dtype is ``uint8``
|
211 |
+
- ``16`` if dtype is ``int16``
|
212 |
+
- ``32`` if dtype is ``int32`` or ``float32``
|
213 |
+
|
214 |
+
- ``8`` if ``encoding`` is ``"PCM_U"``, ``"ULAW"`` or ``"ALAW"``
|
215 |
+
- ``16`` if ``encoding`` is ``"PCM_S"``
|
216 |
+
- ``32`` if ``encoding`` is ``"PCM_F"``
|
217 |
+
|
218 |
+
``"flac"`` format;
|
219 |
+
- the default value is ``24``
|
220 |
+
|
221 |
+
``"sph"`` format;
|
222 |
+
- ``16`` if ``encoding`` is ``"PCM_U"``, ``"PCM_S"``, ``"PCM_F"`` or not provided.
|
223 |
+
- ``8`` if ``encoding`` is ``"ULAW"`` or ``"ALAW"``
|
224 |
+
|
225 |
+
``"amb"`` format;
|
226 |
+
- ``8`` if ``encoding`` is ``"PCM_U"``, ``"ULAW"`` or ``"ALAW"``
|
227 |
+
- ``16`` if ``encoding`` is ``"PCM_S"`` or not provided.
|
228 |
+
- ``32`` if ``encoding`` is ``"PCM_F"``
|
229 |
+
|
230 |
+
Supported formats/encodings/bit depth/compression are;
|
231 |
+
|
232 |
+
``"wav"``, ``"amb"``
|
233 |
+
- 32-bit floating-point PCM
|
234 |
+
- 32-bit signed integer PCM
|
235 |
+
- 24-bit signed integer PCM
|
236 |
+
- 16-bit signed integer PCM
|
237 |
+
- 8-bit unsigned integer PCM
|
238 |
+
- 8-bit mu-law
|
239 |
+
- 8-bit a-law
|
240 |
+
|
241 |
+
Note: Default encoding/bit depth is determined by the dtype of the input Tensor.
|
242 |
+
|
243 |
+
``"mp3"``
|
244 |
+
Fixed bit rate (such as 128kHz) and variable bit rate compression.
|
245 |
+
Default: VBR with high quality.
|
246 |
+
|
247 |
+
``"flac"``
|
248 |
+
- 8-bit
|
249 |
+
- 16-bit
|
250 |
+
- 24-bit (default)
|
251 |
+
|
252 |
+
``"ogg"``, ``"vorbis"``
|
253 |
+
- Different quality level. Default: approx. 112kbps
|
254 |
+
|
255 |
+
``"sph"``
|
256 |
+
- 8-bit signed integer PCM
|
257 |
+
- 16-bit signed integer PCM
|
258 |
+
- 24-bit signed integer PCM
|
259 |
+
- 32-bit signed integer PCM (default)
|
260 |
+
- 8-bit mu-law
|
261 |
+
- 8-bit a-law
|
262 |
+
- 16-bit a-law
|
263 |
+
- 24-bit a-law
|
264 |
+
- 32-bit a-law
|
265 |
+
|
266 |
+
``"amr-nb"``
|
267 |
+
Bitrate ranging from 4.75 kbit/s to 12.2 kbit/s. Default: 4.75 kbit/s
|
268 |
+
|
269 |
+
``"gsm"``
|
270 |
+
Lossy Speech Compression, CPU intensive.
|
271 |
+
|
272 |
+
``"htk"``
|
273 |
+
Uses a default single-channel 16-bit PCM format.
|
274 |
+
|
275 |
+
Note:
|
276 |
+
To save into formats that ``libsox`` does not handle natively, (such as ``"mp3"``,
|
277 |
+
``"flac"``, ``"ogg"`` and ``"vorbis"``), your installation of ``torchaudio`` has
|
278 |
+
to be linked to ``libsox`` and corresponding codec libraries such as ``libmad``
|
279 |
+
or ``libmp3lame`` etc.
|
280 |
+
"""
|
281 |
+
if not torch.jit.is_scripting():
|
282 |
+
if hasattr(filepath, "write"):
|
283 |
+
raise RuntimeError("sox_io backend does not handle file-like object.")
|
284 |
+
filepath = os.fspath(filepath)
|
285 |
+
sox_ext.save_audio_file(
|
286 |
+
filepath,
|
287 |
+
src,
|
288 |
+
sample_rate,
|
289 |
+
channels_first,
|
290 |
+
compression,
|
291 |
+
format,
|
292 |
+
encoding,
|
293 |
+
bits_per_sample,
|
294 |
+
)
|
MLPY/Lib/site-packages/torchaudio/backend/common.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def __getattr__(name: str):
|
2 |
+
if name == "AudioMetaData":
|
3 |
+
import warnings
|
4 |
+
|
5 |
+
warnings.warn(
|
6 |
+
"`torchaudio.backend.common.AudioMetaData` has been moved to "
|
7 |
+
"`torchaudio.AudioMetaData`. Please update the import path.",
|
8 |
+
stacklevel=2,
|
9 |
+
)
|
10 |
+
from torchaudio import AudioMetaData
|
11 |
+
|
12 |
+
return AudioMetaData
|
13 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
MLPY/Lib/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)
|
MLPY/Lib/site-packages/torchaudio/backend/soundfile_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 torchaudio._backend import soundfile_backend
|
13 |
+
|
14 |
+
return getattr(soundfile_backend, name)
|
MLPY/Lib/site-packages/torchaudio/backend/sox_io_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 _sox_io_backend
|
13 |
+
|
14 |
+
return getattr(_sox_io_backend, name)
|