Abdullah Hamdan Abdullah Hamdan - 1 year ago 126
Python Question

looking for reading audio wave values in python

I'm trying to read and manipulate audio file ,
how to read and manipulate the waves value of a wave file using python?

Answer Source

The SciPy libraries have great resources for this:

Writing and Reading:

import numpy as np
from scipy.io import wavfile

fs = 44.1e3
t = np.arange(0, 1.0, 1.0/fs)

f1 = 440
f2 = 600

x = 0.5*np.sin(2*np.pi*f1*t) + 0.5*np.sin(2*np.pi*f2*t)

fname = 'output.wav'
wavfile.write( fname, fs, x )

fs, data = wavfile.read( fname )

print fs, data[:10]

Documentation: http://docs.scipy.org/doc/scipy-0.14.0/reference/io.html#module-scipy.io.wavfile

This question has been asked before: How to read *.wav file in Python?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download