http://cournape.github.io/audiolab/
This has support for a lot of formats, but you may have to install it manually.
Works with pcm16, pcm24, pcm32, float32 (both WAV and WAVEX).
Audio data is returned as NumPy array, default dtype
is float64
.
This can be changed with the dtype=
argument, but there is currently (in version 0.11.0) a bug (see https://github.com/cournape/audiolab/issues/3)!
Advantages:
audiolab.available_file_formats()
and audiolab.available_encodings()
Disadvantages:
dtype != float64
Installation:
python2 -m pip install scikits.audiolab
import matplotlib.pyplot as plt
import numpy as np
from scikits.audiolab import Sndfile, Format
import contextlib
with contextlib.closing(Sndfile('data/test_wav_pcm16.wav')) as f:
print "sampling rate = {} Hz, length = {} samples, channels = {}".format(f.samplerate, f.nframes, f.channels)
# default dtype: float64
sig = f.read_frames(f.nframes)
print "dtype: {}".format(sig.dtype)
plt.plot(sig);
sampling rate = 44100 Hz, length = 15 samples, channels = 7 dtype: float64
32-bit float and WAVEX are supported:
with contextlib.closing(Sndfile('data/test_wavex_float32.wav')) as f:
sig = f.read_frames(f.nframes)
print "dtype: {}".format(sig.dtype)
plt.plot(sig);
dtype: float64
But, if another type than float64
is requested, things go wrong!
... at least in version 0.11.0, see https://github.com/cournape/audiolab/issues/3.
with contextlib.closing(Sndfile('data/test_wav_pcm16.wav')) as f:
sig = f.read_frames(f.nframes, dtype=np.float32)
plt.plot(sig);
Nice format information:
Sndfile('data/test_wavex_float32.wav').format
Major Format: WAVEX (Microsoft) Encoding Format: 32 bit float Endianness: file
TODO
from scikits import audiolab
audiolab.__version__
'0.11.0'