TorchAudio Ruby

February 27, 2026 · View on GitHub

:fire: An audio library for Torch.rb

Build Status

Installation

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!

Basics

Load a file (requires torchcodec)

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

Save a file (requires torchcodec)

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

Transforms

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

Supported transforms are:

  • AmplitudeToDB
  • ComputeDeltas
  • Fade
  • MelScale
  • MelSpectrogram
  • MFCC
  • MuLawDecoding
  • MuLawEncoding
  • Spectrogram
  • Vol

Functional

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

Supported functions are:

  • amplitude_to_DB
  • compute_deltas
  • create_dct
  • create_fb_matrix
  • DB_to_amplitude
  • 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.

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-ruby.git
cd torchaudio-ruby
bundle install
bundle exec rake compile
bundle exec rake test