Skip to main content

Convert WAV files to Mel spectrograms

Project description

wav2mel

Converts WAV audio [1] to Mel spectrograms for use in machine learning systems like Tacotron2.

This library contains portions of the copy-pasted code you see everywhere for WAV to Mel conversion.

[1] Or any audio format supported by librosa (which uses soundfile and audioread).

Installation

pip install wav2mel

Dependencies

  • Python 3.6 or higher
  • librosa, numpy, scipy, numba

Format

wav2mel outputs numpy save data: one .npy file each input file.

Usage

You can convert a single WAVE file from .wav to a mel spectrogram (.npy) as follows:

wav2mel < WAVE_FILE > NPY_FILE

Multiple WAVE files can also be converted and saved to a directory:

wav2mel --output-dir /path/to/mels WAVE_FILE [WAVE_FILE ...]

Each .npy file will be named after the corresponding .wav file.

See wav2mel --help for more options (filter/hop/window length, sample rate, etc.).

With GNU Parallel

find /path/to/wavs -name '*.wav' -type f | parallel -X wav2mel --output-dir /path/to/mels

mel2wav (Griffin-Lim)

You can convert a mel spectrogram to WAV audio too using griffin-lim:

mel2wav < NPY_FILE > WAVE_FILE

or

mel2wav --output-dir /path/to/wavs NPY_FILE [NPY_FILE ...]

See mel2wav --help for more options.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wav2mel-0.3.0.tar.gz (7.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page