def __init__(self, which_set, frame_length, overlap=0, lpc_order=10,
                 frames_per_example=1, start=0, stop=None, audio_only=False,
                 rng=_default_seed):
        """
        Parameters
        ----------
        which_set : str
            Either "train", "valid" or "test"
        frame_length : int
            Number of acoustic samples contained in a frame
        overlap : int, optional
            Number of overlapping acoustic samples for two consecutive frames.
            Defaults to 0, meaning frames don't overlap.
        frames_per_example : int, optional
            Number of frames in a training example. Defaults to 1.
        start : int, optional
            Starting index of the sequences to use. Defaults to 0.
        stop : int, optional
            Ending index of the sequences to use. Defaults to `None`, meaning
            sequences are selected all the way to the end of the array.
        audio_only : bool, optional
            Whether to load only the raw audio and no auxiliary information.
            Defaults to `False`.
        rng : object, optional
            A random number generator used for picking random indices into the
            design matrix when choosing minibatches.
        """
        self.frame_length = frame_length
        self.overlap = overlap
        self.frames_per_example = frames_per_example
        self.lpc_order = lpc_order
        self.offset = self.frame_length - self.overlap
        self.audio_only = audio_only

        # RNG initialization
        if hasattr(rng, 'random_integers'):
            self.rng = rng
        else:
            self.rng = numpy.random.RandomState(rng)

        # Load data from disk
        self._load_data(which_set)
        # Standardize data
        # for i, sequence in enumerate(self.raw_wav):
        #     self.raw_wav[i] = (sequence - TIMIT._mean) / TIMIT._std

        # Slice data
        if stop is not None:
            self.raw_wav = self.raw_wav[start:stop]
            if not self.audio_only:
                self.phones = self.phones[start:stop]
                self.phonemes = self.phonemes[start:stop]
                self.words = self.words[start:stop]
        else:
            self.raw_wav = self.raw_wav[start:]
            if not self.audio_only:
                self.phones = self.phones[start:]
                self.phonemes = self.phonemes[start:]
                self.words = self.words[start:]

        examples_per_sequence = [0]

        for sequence_id, samples_sequence in enumerate(self.raw_wav):
            if not self.audio_only:
                # Phones segmentation
                phones_sequence = self.phones[sequence_id]
                phones_segmented_sequence = segment_axis(phones_sequence,
                                                         frame_length,
                                                         overlap)
                self.phones[sequence_id] = phones_segmented_sequence
                # phones_segmented_sequence = scipy.stats.mode(
                #     phones_segmented_sequence,
                #     axis=1
                # )[0].flatten()
                # phones_segmented_sequence = numpy.asarray(
                #     phones_segmented_sequence,
                #     dtype='int'
                # )
                # phones_sequence_list.append(phones_segmented_sequence)
                # Phonemes segmentation
                phonemes_sequence = self.phonemes[sequence_id]
                phonemes_segmented_sequence = segment_axis(phonemes_sequence,
                                                           frame_length,
                                                           overlap)
                self.phonemes[sequence_id] = phonemes_segmented_sequence
                # phonemes_segmented_sequence = scipy.stats.mode(
                #     phonemes_segmented_sequence,
                #     axis=1
                # )[0].flatten()
                # phonemes_segmented_sequence = numpy.asarray(
                #     phonemes_segmented_sequence,
                #     dtype='int'
                # )
                # phonemes_sequence_list.append(phonemes_segmented_sequence)
                # Words segmentation
                words_sequence = self.words[sequence_id]
                words_segmented_sequence = segment_axis(words_sequence,
                                                        frame_length,
                                                        overlap)
                self.words[sequence_id] = words_segmented_sequence
                # words_segmented_sequence = scipy.stats.mode(
                #     words_segmented_sequence,
                #     axis=1
                # )[0].flatten()
                # words_segmented_sequence = numpy.asarray(words_segmented_sequence,
                #                                          dtype='int')
                # words_sequence_list.append(words_segmented_sequence)

            # TODO: look at this, does it force copying the data?
            # Sequence segmentation
            samples_segmented_sequence = segment_axis(samples_sequence,
                                                      frame_length,
                                                      overlap)
            self.raw_wav[sequence_id] = samples_segmented_sequence

            # TODO: change me
            # Generate features/targets/phones/phonemes/words map
            num_frames = samples_segmented_sequence.shape[0]
            num_examples = num_frames - self.frames_per_example
            examples_per_sequence.append(num_examples)

        self.cumulative_example_indexes = numpy.cumsum(examples_per_sequence)
        self.samples_sequences = self.raw_wav
        if not self.audio_only:
            self.phones_sequences = self.phones
            self.phonemes_sequences = self.phonemes
            self.words_sequences = self.words
        self.num_examples = self.cumulative_example_indexes[-1]

        # DataSpecs
        # features_space = VectorSpace(
        #     dim=self.frame_length * self.frames_per_example
        # )
        # features_source = 'features'
        # features_dtype = self.samples_sequences[0].dtype
        # def features_map_fn(indexes):
        #     rval = []
        #     for sequence_index, example_index in self._fetch_index(indexes):
        #         rval.append(self.samples_sequences[sequence_index][example_index:example_index
        #             + self.frames_per_example].ravel())
        #     return rval

        targets_space = VectorSpace(
            dim=self.lpc_order
        )
        targets_source = 'targets'
        targets_dtype = numpy.float64
        def targets_map_fn(indexes):
            rval = []
            for sequence_index, example_index in self._fetch_index(indexes):
                rval.append(lpc(self.samples_sequences[sequence_index][example_index].T,self.lpc_order)[0][1:].ravel())
            return rval

        features_space = IndexSpace(max_labels=62, dim=3)
        features_source = 'features'
        features_dtype = numpy.int16
        def features_map_fn(indexes):
            rval = []
            for sequence_index, example_index in self._fetch_index(indexes):
                if example_index != 0:
                    if example_index != self.num_examples-1:
                        rval.append(numpy.asarray(scipy.stats.mode(self.phones_sequences[sequence_index][(example_index-1):(example_index+2)], axis=1)[0].T, dtype=numpy.int16))
                    else:
                        rval.append(numpy.asarray(numpy.concatenate([scipy.stats.mode(self.phones_sequences[sequence_index][example_index-1:example_index+1], axis=1)[0].T, numpy.zeros((1,1))], axis=1).ravel(), dtype=numpy.int16))
                else:
                    rval.append(numpy.asarray(numpy.concatenate([numpy.zeros((1,1)), scipy.stats.mode(self.phones_sequences[sequence_index][example_index:example_index+2].T)[0].T]).ravel(), dtype=numpy.int16))
            return rval

        # targets_space = VectorSpace(dim=self.frame_length)
        # targets_source = 'targets'
        # targets_dtype = self.samples_sequences[0].dtype
        # def targets_map_fn(indexes):
        #     rval = []
        #     for sequence_index, example_index in self._fetch_index(indexes):
        #         rval.append(self.samples_sequences[sequence_index][example_index
        #             + self.frames_per_example].ravel())
        #     return rval

        space_components = [features_space, targets_space]
        source_components = [features_source, targets_source]
        dtypes_components = [features_dtype, targets_dtype]
        map_fn_components = [features_map_fn, targets_map_fn]
        batch_components = [None, None]

        # if not self.audio_only:
        #     phones_space = IndexSpace(max_labels=62, dim=3)
        #     phones_source = 'phones'
        #     phones_dtype = self.phones_sequences[0].dtype
        #     def phones_map_fn(indexes):
        #         rval = []
        #         for sequence_index, example_index in self._fetch_index(indexes):
        #             if example_index != 0:
        #                 if example_index != self.num_examples-1:
        #                     rval.append(scipy.stats.mode(self.phones_sequences[sequence_index][(example_index-1):(example_index+2)], axis=1)[0].T)
        #                 else:
        #                     rval.append(numpy.concatenate([scipy.stats.mode(self.phones_sequences[sequence_index][example_index-1:example_index+1], axis=1)[0].T, numpy.zeros((1,1))], axis=1)).ravel()
        #             else:
        #                 rval.append(numpy.concatenate([numpy.zeros((1,1)), scipy.stats.mode(self.phones_sequences[sequence_index][example_index:example_index+1])[0].T])).ravel()
        #         return rval

        #     phonemes_space = IndexSpace(max_labels=31, dim=1)
        #     phonemes_source = 'phonemes'
        #     phonemes_dtype = self.phonemes_sequences[0].dtype
        #     def phonemes_map_fn(indexes):
        #         rval = []
        #         for sequence_index, example_index in self._fetch_index(indexes):
        #             rval.append(self.phonemes_sequences[sequence_index][example_index
        #                 + self.frames_per_example].ravel())
        #         return rval

        #     words_space = IndexSpace(max_labels=31, dim=1)
        #     words_source = 'words'
        #     words_dtype = self.words_sequences[0].dtype
        #     def words_map_fn(indexes):
        #         rval = []
        #         for sequence_index, example_index in self._fetch_index(indexes):
        #             rval.append(self.words_sequences[sequence_index][example_index
        #                 + self.frames_per_example].ravel())
        #         return rval

        #     space_components.extend([phones_space, phonemes_space,
        #                              words_space])
        #     source_components.extend([phones_source, phonemes_source,
        #                              words_source])
        #     dtypes_components.extend([phones_dtype, phonemes_dtype,
        #                              words_dtype])
        #     map_fn_components.extend([phones_map_fn, phonemes_map_fn,
        #                              words_map_fn])
        #     batch_components.extend([None, None, None])

        space = CompositeSpace(space_components)
        source = tuple(source_components)
        self.data_specs = (space, source)
        self.dtypes = tuple(dtypes_components)
        self.map_functions = tuple(map_fn_components)
        self.batch_buffers = batch_components

        # Defaults for iterators
        self._iter_mode = resolve_iterator_class('shuffled_sequential')
        self._iter_data_specs = (CompositeSpace((features_space,
                                                 targets_space)),
                                 (features_source, targets_source))
dataset/ETHPy150Open jfsantos/ift6266h14/old/pylearn2_timit/timitlpc.py/TIMITlpc.__init__/original