Python samplerate

From wikinotes

samplerate is a set of python bindings for libsamplerate. It can use a variety of algorithms to adjust the samplerate of a wavfile expressed as a numpy array using a multiplier.

It cannot convert to an exact samplerate, you would need to perform the appropriate calculations yourself.

NOTE:

If targeting a specific samplerate, you may find python resampy more useful

Usage

import numpy
import samplerate
import wavio

numpy_array = wavio.read('file.wav')
resampled_array = samplerate.resample(numpy_array, ratio=1.5)