Skip to content
forked from pytorch/audio

Data manipulation and transformation for audio signal processing, powered by PyTorch

License

Notifications You must be signed in to change notification settings

MarktHart/audio

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

torchaudio: an audio library for PyTorch

Build Status Documentation Anaconda Badge Anaconda-Server Badge

The aim of torchaudio is to apply PyTorch to the audio domain. By supporting PyTorch, torchaudio follows the same philosophy of providing strong GPU acceleration, having a focus on trainable features through the autograd system, and having consistent style (tensor names and dimension names). Therefore, it is primarily a machine learning library and not a general signal processing library. The benefits of PyTorch can be seen in torchaudio through having all the computations be through PyTorch operations which makes it easy to use and feel like a natural extension.

Dependencies

  • PyTorch (See below for the compatible versions)
  • [optional] vesis84/kaldi-io-for-python commit cb46cb1f44318a5d04d4941cf39084c5b021241e or above

The following are the corresponding torchaudio versions and supported Python versions.

torch torchaudio python
Development master / nightly main / nightly >=3.7, <=3.10
Latest versioned release 1.12.0 0.12.0 >=3.7, <=3.10
LTS 1.8.2 0.8.2 >=3.6, <=3.9
Previous versions
torch torchaudio python
1.11.0 0.11.0 >=3.7, <=3.9
1.10.0 0.10.0 >=3.6, <=3.9
1.9.1 0.9.1 >=3.6, <=3.9
1.9.0 0.9.0 >=3.6, <=3.9
1.8.2 0.8.2 >=3.6, <=3.9
1.8.0 0.8.0 >=3.6, <=3.9
1.7.1 0.7.2 >=3.6, <=3.9
1.7.0 0.7.0 >=3.6, <=3.8
1.6.0 0.6.0 >=3.6, <=3.8
1.5.0 0.5.0 >=3.5, <=3.8
1.4.0 0.4.0 ==2.7, >=3.5, <=3.8

Installation

Binary Distributions

torchaudio has binary distributions for PyPI (pip) and Anaconda (conda).

Please refer to https://pytorch.org/get-started/locally/ for the details.

Note Starting 0.10, torchaudio has CPU-only and CUDA-enabled binary distributions, each of which requires a matching PyTorch version.

Note LTS versions are distributed through a different channel than the other versioned releases. Please refer to the above page for details.

Note This software was compiled against an unmodified copy of FFmpeg (licensed under the LGPLv2.1), with the specific rpath removed so as to enable the use of system libraries. The LGPL source can be downloaded here.

From Source

On non-Windows platforms, the build process builds libsox and codecs that torchaudio need to link to. It will fetch and build libmad, lame, flac, vorbis, opus, and libsox before building extension. This process requires cmake and pkg-config. libsox-based features can be disabled with BUILD_SOX=0. The build process also builds the RNN transducer loss and CTC beam search decoder. These functionalities can be disabled by setting the environment variable BUILD_RNNT=0 and BUILD_CTC_DECODER=0, respectively.

# Linux
python setup.py install

# OSX
CC=clang CXX=clang++ python setup.py install

# Windows
# We need to use the MSVC x64 toolset for compilation, with Visual Studio's vcvarsall.bat or directly with vcvars64.bat.
# These batch files are under Visual Studio's installation folder, under 'VC\Auxiliary\Build\'.
# More information available at:
#   https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-160#use-vcvarsallbat-to-set-a-64-bit-hosted-build-architecture
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 && set BUILD_SOX=0 && python setup.py install
# or
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" && set BUILD_SOX=0 && python setup.py install

This is known to work on linux and unix distributions such as Ubuntu and CentOS 7 and macOS. If you try this on a new system and find a solution to make it work, feel free to share it by opening an issue.

Quick Usage

import torchaudio

waveform, sample_rate = torchaudio.load('foo.wav')  # load tensor from file
torchaudio.save('foo_save.wav', waveform, sample_rate)  # save tensor to file

Backend Dispatch

By default in OSX and Linux, torchaudio uses SoX as a backend to load and save files. The backend can be changed to SoundFile using the following. See SoundFile for installation instructions.

import torchaudio
torchaudio.set_audio_backend("soundfile")  # switch backend

waveform, sample_rate = torchaudio.load('foo.wav')  # load tensor from file, as usual
torchaudio.save('foo_save.wav', waveform, sample_rate)  # save tensor to file, as usual

Note

  • SoundFile currently does not support mp3.
  • "soundfile" backend is not supported by TorchScript.

API Reference

API Reference is located here: http://pytorch.org/audio/main/

Contributing Guidelines

Please refer to CONTRIBUTING.md

Citation

If you find this package useful, please cite as:

@article{yang2021torchaudio,
  title={TorchAudio: Building Blocks for Audio and Speech Processing},
  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},
  journal={arXiv preprint arXiv:2110.15018},
  year={2021}
}

Disclaimer on Datasets

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.

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!

About

Data manipulation and transformation for audio signal processing, powered by PyTorch

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 78.9%
  • C++ 15.8%
  • Shell 1.8%
  • CMake 1.4%
  • Cuda 1.2%
  • Batchfile 0.7%
  • Dockerfile 0.2%