TorchAudio

:fire: An audio library for Torch.rb

Build Status

Installation

First, install SoX. For Homebrew, use:

brew install sox

Add this line to your application’s Gemfile:

gem 'torchaudio'

Getting Started

This library follows the Python API. Many methods and options are missing at the moment. PRs welcome!

Tutorial

Download the audio file and install the matplotlib gem first.

Basics

Load a file

waveform, sample_rate = TorchAudio.load("file.wav")

Save a file

TorchAudio.save("new.wave", waveform, sample_rate)

Transforms

TorchAudio::Transforms::Spectrogram.new.call(waveform)

Supported transforms are:

  • MelSpectrogram
  • MuLawDecoding
  • MuLawEncoding
  • Spectrogram

Functional

TorchAudio::Functional.lowpass_biquad(waveform, sample_rate, cutoff_freq)

Supported functions are:

  • compute_deltas
  • dither
  • gain
  • highpass_biquad
  • lowpass_biquad
  • mu_law_decoding
  • mu_law_encoding
  • spectrogram

Datasets

Load a dataset

TorchAudio::Datasets::YESNO.new(".", download: true)

Supported datasets are:

Disclaimer

This library downloads and prepares public datasets. We don’t host any datasets. Be sure to adhere to the license for each dataset.

If you’re a dataset owner and wish to update any details or remove it from this project, let us know.

SoX Installation

Mac

brew install sox

Windows

todo

Ubuntu

sudo apt install sox libsox-dev libsox-fmt-all

Travis CI

Add to .travis.yml:

addons:
  apt:
    packages:
      - sox
      - libsox-dev
      - libsox-fmt-all

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/torchaudio.git
cd torchaudio
bundle install
bundle exec rake compile
bundle exec rake test