scipy/io/wavfile.py
def read(filename, mmap=False):
    """
    Return the sample rate (in samples/sec) and data from a WAV file

    Parameters
    ----------
    filename : string or open file handle
        Input wav file.
    mmap : bool, optional
        Whether to read data as memory mapped.
        Only to be used on real files (Default: False)

        .. versionadded:: 0.12.0

    Returns
    -------
    rate : int
        Sample rate of wav file
    data : numpy array
        Data read from wav file

    Notes
    -----
    * The file can be an open file or a filename.
    * The returned sample rate is a Python integer.
    * The data is returned as a numpy array with a data-type determined
      from the file.
    * This function cannot read wav files with 24 bit data.

    """
    if hasattr(filename, 'read'):
        fid = filename
        mmap = False
    else:
        fid = open(filename, 'rb')

    try:
        fsize, is_big_endian = _read_riff_chunk(fid)
        fmt_chunk_received = False
        noc = 1
        bits = 8
        comp = WAVE_FORMAT_PCM
        while (fid.tell() < fsize):
            # read the next chunk
            chunk_id = fid.read(4)
            if chunk_id == b'fmt ':
                fmt_chunk_received = True
                size, comp, noc, rate, sbytes, ba, bits = _read_fmt_chunk(fid, is_big_endian=is_big_endian)
                if bits == 24:
                    raise ValueError("Unsupported bit depth: the wav file "
                                     "has 24 bit data.")
            elif chunk_id == b'fact':
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            elif chunk_id == b'data':
                if not fmt_chunk_received:
                    raise ValueError("No fmt chunk before data")
                data = _read_data_chunk(fid, comp, noc, bits, is_big_endian=is_big_endian, mmap=mmap)
            elif chunk_id == b'LIST':
                # Someday this could be handled properly but for now skip it
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            elif chunk_id in (b'JUNK', b'Fake'):
                # Skip alignment chunks without warning
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            else:
                warnings.warn("Chunk (non-data) not understood, skipping it.",
                              WavFileWarning)
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
    finally:
        if not hasattr(filename, 'read'):
            fid.close()
        else:
            fid.seek(0)

    return rate, data

    Return the sample rate (in samples/sec) and data from a WAV file

    Parameters
    ----------
    filename : string or open file handle
        Input wav file.
    mmap : bool, optional
        Whether to read data as memory mapped.
        Only to be used on real files (Default: False)

        .. versionadded:: 0.12.0

    Returns
    -------
    rate : int
        Sample rate of wav file
    data : numpy array
        Data read from wav file

    Notes
    -----
    * The file can be an open file or a filename.
    * The returned sample rate is a Python integer.
    * The data is returned as a numpy array with a data-type determined
      from the file.
    * This function cannot read wav files with 24 bit data.

    
Return the sample rate (in samples/sec) and data from a WAV file
Parameters

filename : string or open file handle
Input wav file.
mmap : bool, optional
Whether to read data as memory mapped.
Only to be used on real files (Default: False)



Returns

rate : int
Sample rate of wav file
data : numpy array
Data read from wav file

Notes

The file can be an open file or a filename.
The returned sample rate is a Python integer.
The data is returned as a numpy array with a data-type determined
from the file.
This function cannot read wav files with 24 bit data.
Return the sample rate ( in samples / sec ) and data from a WAV file Parameters filename : string or open file handle Input wav file . mmap : bool optional Whether to read data as memory mapped . Only to be used on real files ( Default : False ) Returns rate : int Sample rate of wav file data : numpy array Data read from wav file Notes The file can be an open file or a filename . The returned sample rate is a Python integer . The data is returned as a numpy array with a data - type determined from the file . This function cannot read wav files with 24 bit data .
def read(filename, mmap=False):
    if hasattr(filename, 'read'):
        fid = filename
        mmap = False
    else:
        fid = open(filename, 'rb')
    try:
        fsize, is_big_endian = _read_riff_chunk(fid)
        fmt_chunk_received = False
        noc = 1
        bits = 8
        comp = WAVE_FORMAT_PCM
        while (fid.tell() < fsize):
            chunk_id = fid.read(4)
            if chunk_id == b'fmt ':
                fmt_chunk_received = True
                size, comp, noc, rate, sbytes, ba, bits = _read_fmt_chunk(fid, is_big_endian=is_big_endian)
                if bits == 24:
                    raise ValueError("Unsupported bit depth: the wav file "
                                     "has 24 bit data.")
            elif chunk_id == b'fact':
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            elif chunk_id == b'data':
                if not fmt_chunk_received:
                    raise ValueError("No fmt chunk before data")
                data = _read_data_chunk(fid, comp, noc, bits, is_big_endian=is_big_endian, mmap=mmap)
            elif chunk_id == b'LIST':
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            elif chunk_id in (b'JUNK', b'Fake'):
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
            else:
                warnings.warn("Chunk (non-data) not understood, skipping it.",
                              WavFileWarning)
                _skip_unknown_chunk(fid, is_big_endian=is_big_endian)
    finally:
        if not hasattr(filename, 'read'):
            fid.close()
        else:
            fid.seek(0)
    return rate, data
def read ( filename , mmap = False ) : if hasattr ( filename , 'read' ) : fid = filename mmap = False else : fid = open ( filename , 'rb' ) try : fsize , is_big_endian = _read_riff_chunk ( fid ) fmt_chunk_received = False noc = 1 bits = 8 comp = WAVE_FORMAT_PCM while ( fid . tell ( ) < fsize ) : chunk_id = fid . read ( 4 ) if chunk_id == b'fmt ' : fmt_chunk_received = True size , comp , noc , rate , sbytes , ba , bits = _read_fmt_chunk ( fid , is_big_endian = is_big_endian ) if bits == 24 : raise ValueError ( "Unsupported bit depth: the wav file " "has 24 bit data." ) elif chunk_id == b'fact' : _skip_unknown_chunk ( fid , is_big_endian = is_big_endian ) elif chunk_id == b'data' : if not fmt_chunk_received : raise ValueError ( "No fmt chunk before data" ) data = _read_data_chunk ( fid , comp , noc , bits , is_big_endian = is_big_endian , mmap = mmap ) elif chunk_id == b'LIST' : _skip_unknown_chunk ( fid , is_big_endian = is_big_endian ) elif chunk_id in ( b'JUNK' , b'Fake' ) : _skip_unknown_chunk ( fid , is_big_endian = is_big_endian ) else : warnings . warn ( "Chunk (non-data) not understood, skipping it." , WavFileWarning ) _skip_unknown_chunk ( fid , is_big_endian = is_big_endian ) finally : if not hasattr ( filename , 'read' ) : fid . close ( ) else : fid . seek ( 0 ) return rate , data
Return the sample rate (in samples/sec) and data from a WAV file
Parameters
Return the sample rate ( in samples / sec ) and data from a WAV file Parameters
"""
    Return the sample rate (in samples/sec) and data from a WAV file

    Parameters
    ----------
    filename : string or open file handle
        Input wav file.
    mmap : bool, optional
        Whether to read data as memory mapped.
        Only to be used on real files (Default: False)

        .. versionadded:: 0.12.0

    Returns
    -------
    rate : int
        Sample rate of wav file
    data : numpy array
        Data read from wav file

    Notes
    -----
    * The file can be an open file or a filename.
    * The returned sample rate is a Python integer.
    * The data is returned as a numpy array with a data-type determined
      from the file.
    * This function cannot read wav files with 24 bit data.

    """ # read the next chunk # Someday this could be handled properly but for now skip it # Skip alignment chunks without warning
filename
mmap