'Returns the next batch of data.'

def next(self):

    if (self.curr_idx == len(self.idx)):
        raise StopIteration
    (i, j) = self.idx[self.curr_idx]
    self.curr_idx += 1
    audio_paths = []
    texts = []
    for (duration, audio_path, text) in self.data[i][j:(j + self.batch_size)]:
        audio_paths.append(audio_path)
        texts.append(text)
    if self.is_first_epoch:
        data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=True, is_bi_graphemes=self.is_bi_graphemes, seq_length=self.buckets[i], save_feature_as_csvfile=self.save_feature_as_csvfile)
    else:
        data_set = self.datagen.prepare_minibatch(audio_paths, texts, overwrite=False, is_bi_graphemes=self.is_bi_graphemes, seq_length=self.buckets[i], save_feature_as_csvfile=self.save_feature_as_csvfile)
    data_all = ([mx.nd.array(data_set['x'])] + self.init_state_arrays)
    label_all = [mx.nd.array(data_set['y'])]
    self.label = label_all
    provide_data = ([('data', (self.batch_size, self.buckets[i], (self.width * self.height)))] + self.init_states)
    return mx.io.DataBatch(data_all, label_all, pad=0, bucket_key=self.buckets[i], provide_data=provide_data, provide_label=self.provide_label)
