# python-scipyHow can I use Python and SciPy to read and write WAV files?

Python and SciPy can be used to read and write WAV files. The `scipy.io.wavfile`

module provides functions for reading and writing WAV files.

## Example code

```
from scipy.io import wavfile
# Read the wav file (samplerate, data)
samplerate, data = wavfile.read('file.wav')
# Write the wav file
wavfile.write('file_new.wav', samplerate, data)
```

The `wavfile.read`

function reads a WAV file and returns the sample rate and data as a tuple. The sample rate is the number of samples per second and the data is an array of integers representing the amplitude of the sound. The `wavfile.write`

function writes a WAV file, taking the sample rate and data as parameters.

## Code explanation

`from scipy.io import wavfile`

: imports the`wavfile`

module from the`scipy.io`

package`samplerate, data = wavfile.read('file.wav')`

: reads the WAV file and returns the sample rate and data as a tuple`wavfile.write('file_new.wav', samplerate, data)`

: writes a WAV file, taking the sample rate and data as parameters

## Helpful links

### More of Python Scipy

- How can I use the Radial Basis Function (RBF) in Python with SciPy?
- How do I create a 2D array of zeros using Python and NumPy?
- How do I use Python XlsxWriter to write a NumPy array to an Excel file?
- How do I create a numpy array of zeros using Python?
- How can I use Python and Numpy to parse XML data?
- How do I create a zero matrix using Python and Numpy?
- How do I create a numpy array of zeros using Python?
- How do I create an array of zeros with the same shape as an existing array using Python and NumPy?
- How can I use Python and Numpy to zip files?
- How can I use Python and SciPy to find the zeros of a function?

See more codes...