tools/utilities/pythonlibs/audio/wav_reader.py
def read(self):
        """ Reads the next chunk of audio (returns buffer_size provided to open)
        It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
        values possible for the given audio format.
        """

        if self.wav_file is None:
            return None
        data = self.wav_file.readframes(self.buffer_size)   
        if len(data) == 0:
            return None

        if self.actual_channels != self.requested_channels:
            if self.requested_channels == 1:
                data = audioop.tomono(data, self.sample_width, 1, 1)
            else:
                raise Exception("Target number of channels must be 1")
                        
        if self.actual_rate != self.requested_rate:
            # convert the audio to the desired recording rate
            data, self.cvstate = audioop.ratecv(data, self.sample_width, self.requested_channels, 
                self.actual_rate, self.requested_rate, self.cvstate)
            
        if self.speaker:
            self.speaker.write(data)

        remainder = len(data) % self.sample_width
        if remainder != 0:
            data = data[:len(data) - remainder]
        data = np.frombuffer(data, dtype=self.dtype).astype(float)

        # pad the last record with zeros so it is valid output.
        data_size = len(data)
        if data_size < self.read_size:
            bigger = np.zeros((self.read_size))
            bigger[:data_size] = data 
            data = bigger
        elif data_size > self.read_size:
            data = data[:self.read_size] # truncate

        return data * self.audio_scale_factor
 Reads the next chunk of audio (returns buffer_size provided to open)
        It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
        values possible for the given audio format.
        
Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format.
Reads the next chunk of audio ( returns buffer_size provided to open ) It returns the data converted to floating point numbers between - 1 and 1 scaled by the range of values possible for the given audio format .
def read(self):
        if self.wav_file is None:
            return None
        data = self.wav_file.readframes(self.buffer_size)   
        if len(data) == 0:
            return None
        if self.actual_channels != self.requested_channels:
            if self.requested_channels == 1:
                data = audioop.tomono(data, self.sample_width, 1, 1)
            else:
                raise Exception("Target number of channels must be 1")
        if self.actual_rate != self.requested_rate:
            data, self.cvstate = audioop.ratecv(data, self.sample_width, self.requested_channels, 
                self.actual_rate, self.requested_rate, self.cvstate)
        if self.speaker:
            self.speaker.write(data)
        remainder = len(data) % self.sample_width
        if remainder != 0:
            data = data[:len(data) - remainder]
        data = np.frombuffer(data, dtype=self.dtype).astype(float)
        data_size = len(data)
        if data_size < self.read_size:
            bigger = np.zeros((self.read_size))
            bigger[:data_size] = data 
            data = bigger
        elif data_size > self.read_size:
            data = data[:self.read_size] 
        return data * self.audio_scale_factor
def read ( self ) : if self . wav_file is None : return None data = self . wav_file . readframes ( self . buffer_size ) if len ( data ) == 0 : return None if self . actual_channels != self . requested_channels : if self . requested_channels == 1 : data = audioop . tomono ( data , self . sample_width , 1 , 1 ) else : raise Exception ( "Target number of channels must be 1" ) if self . actual_rate != self . requested_rate : data , self . cvstate = audioop . ratecv ( data , self . sample_width , self . requested_channels , self . actual_rate , self . requested_rate , self . cvstate ) if self . speaker : self . speaker . write ( data ) remainder = len ( data ) % self . sample_width if remainder != 0 : data = data [ : len ( data ) - remainder ] data = np . frombuffer ( data , dtype = self . dtype ) . astype ( float ) data_size = len ( data ) if data_size < self . read_size : bigger = np . zeros ( ( self . read_size ) ) bigger [ : data_size ] = data data = bigger elif data_size > self . read_size : data = data [ : self . read_size ] return data * self . audio_scale_factor
Reads the next chunk of audio (returns buffer_size provided to open)
It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
values possible for the given audio format.
Reads the next chunk of audio ( returns buffer_size provided to open ) It returns the data converted to floating point numbers between - 1 and 1 scaled by the range of values possible for the given audio format .
""" Reads the next chunk of audio (returns buffer_size provided to open)
        It returns the data converted to floating point numbers between -1 and 1, scaled by the range of
        values possible for the given audio format.
        """ # convert the audio to the desired recording rate # pad the last record with zeros so it is valid output. # truncate
self