Abdullah Hamdan - 1 year ago 126

Python Question

I'm trying to read and manipulate audio file ,

how to read and manipulate the waves value of a wave file using python?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

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

**Reading:**http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.io.wavfile.read.html#scipy.io.wavfile.read**Writing:**http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.io.wavfile.write.html#scipy.io.wavfile.write

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**