[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` read  `

#  scipy.io.wavfile.read  #

scipy.io.wavfile.  read  (  _ filename  _ , _ mmap  =  False  _ )  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/wavfile.py#L541-L706) #

    

Open a WAV file.

Return the sample rate (in samples/sec) and data from an LPCM WAV file.

Parameters  :

    

**filename** string or open file handle

    

Input WAV file.

**mmap** bool, optional

    

Whether to read data as memory-mapped (default: False). Not compatible with
some bit depths; see Notes. Only to be used on real files.

New in version 0.12.0.

Returns  :

    

**rate** int

    

Sample rate of WAV file.

**data** numpy array

    

Data read from WAV file. Data-type is determined from the file; see Notes.
Data is 1-D for 1-channel WAV, or 2-D of shape (Nsamples, Nchannels)
otherwise. If a file-like input without a C-like file descriptor (e.g., [ `
io.BytesIO  ` ](https://docs.python.org/3/library/io.html#io.BytesIO "\(in
Python v3.12\)") ) is passed, this will not be writeable.

Notes

Common data types:  [1]

WAV format  |  Min  |  Max  |  NumPy dtype   
---|---|---|---  
32-bit floating-point  |  -1.0  |  +1.0  |  float32   
32-bit integer PCM  |  -2147483648  |  +2147483647  |  int32   
24-bit integer PCM  |  -2147483648  |  +2147483392  |  int32   
16-bit integer PCM  |  -32768  |  +32767  |  int16   
8-bit integer PCM  |  0  |  255  |  uint8   
  
WAV files can specify arbitrary bit depth, and this function supports reading
any integer PCM depth from 1 to 64 bits. Data is returned in the smallest
compatible numpy int type, in left-justified format. 8-bit and lower is
unsigned, while 9-bit and higher is signed.

For example, 24-bit data will be stored as int32, with the MSB of the 24-bit
data stored at the MSB of the int32, and typically the least significant byte
is 0x00. (However, if a file actually contains data past its specified bit
depth, those bits will be read and output, too.  [2]  )

This bit justification and sign matches WAVâs native internal format, which
allows memory mapping of WAV files that use 1, 2, 4, or 8 bytes per sample (so
24-bit files cannot be memory-mapped, but 32-bit can).

IEEE float PCM in 32- or 64-bit format is supported, with or without mmap.
Values exceeding [-1, +1] are not clipped.

Non-linear PCM (mu-law, A-law) is not supported.

References

[  1  ]

IBM Corporation and Microsoft Corporation, âMultimedia Programming Interface
and Data Specifications 1.0â, section âData Format of the Samplesâ,
August 1991 [ http://www.tactilemedia.com/info/MCI_Control_Info.html
](http://www.tactilemedia.com/info/MCI_Control_Info.html)

[  2  ]

Adobe Systems Incorporated, âAdobe Audition 3 User Guideâ, section
âAudio file formats: 24-bit Packed Int (type 1, 20-bit)â, 2007

Examples