def __init__(self, samples, samplerate=44100, start=0, duration=None):
        '''
            Construct a new ArrayDecoder from an numpy array

            Parameters
            ----------
            samples : numpy array of dimension 1 (mono) or 2 (multichannel)
                    if shape = (n) or (n,1) : n samples, mono
                    if shape = (n,m) : n samples with m channels
            start : float
                start time of the segment in seconds
            duration : float
                duration of the segment in seconds
        '''
        super(ArrayDecoder, self).__init__(start=start, duration=duration)

        # Check array dimension
        if samples.ndim > 2:
            raise TypeError('Wrong number of dimensions for argument samples')
        if samples.ndim == 1:
            samples = samples[:, np.newaxis]  # reshape to 2D array

        self.samples = samples.astype('float32')  # Create a 2 dimensions array
        self.input_samplerate = samplerate
        self.input_channels = self.samples.shape[1]

        self.uri = '_'.join(['raw_audio_array',
                             'x'.join([str(dim) for dim in samples.shape]),
                             samples.dtype.type.__name__])
        from .utils import sha1sum_numpy
        self._sha1 = sha1sum_numpy(self.samples)
        self.frames = self.get_frames()
def __init__ ( self , samples , samplerate = 44100 , start = 0 , duration = None ) : super ( ArrayDecoder , self ) . __init__ ( start = start , duration = duration ) if samples . ndim > 2 : raise TypeError ( 'Wrong number of dimensions for argument samples' ) if samples . ndim == 1 : samples = samples [ : , np . newaxis ] self . samples = samples . astype ( 'float32' ) self . input_samplerate = samplerate self . input_channels = self . samples . shape [ 1 ] self . uri = '_' . join ( [ 'raw_audio_array' , 'x' . join ( [ str ( dim ) for dim in samples . shape ] ) , samples . dtype . type . __name__ ] ) from . utils import sha1sum_numpy self . _sha1 = sha1sum_numpy ( self . samples ) self . frames = self . get_frames ( )
Construct a new ArrayDecoder from an numpy array

            Parameters
            ----------
            samples : numpy array of dimension 1 (mono) or 2 (multichannel)
                    if shape = (n) or (n,1) : n samples, mono
                    if shape = (n,m) : n samples with m channels
            start : float
                start time of the segment in seconds
            duration : float
                duration of the segment in seconds