Various python modules for reading wav:
At least these following libraries read the sound file:
The simplest example:
This is a simple Pysoundfile example:
import soundfile as sf data, samplerate = sf.read('existing_file.wav')
Output format:
Warning. The data is not always in the same format that depends on the library. For example:
from scikits import audiolab from scipy.io import wavfile from sys import argv for filetest in argv[1:]: [x, fs, nbBits] = audiolab.wavread(filePath) print '\nReading with scikits.audiolab.wavread: ', x [fs, x] = wavfile.read(filetest) print '\nReading with scipy.io.wavfile.read: ', x
Reading using scikits.audiolab.wavread: [0. 0. 0 ...., -0.00097656 -0.00079346 -0,00097656] Reading with scipy.io.wavfile.read: [0 0 0 ..., -32 -26 -32]
PySoundFile and Audiolab return a float between -1 and 1 (since matab does this, this is the convention for the audio signal). Scipy and wave return integers that can be converted to float according to the number of coding bits.
For example:
from scipy.io.wavfile import read as wavread [samplerate, x] = wavread(audiofilename)
Patrice Nov 03 '14 at 14:13 2014-11-03 14:13
source share