Beispiel #1
0
 def __init__(self, batch_dim, train_percentage=90):
     from Utilities.Sound import get_sound, sound_cut
     from Utilities.Pretreatment import Normalize
     data = sound_cut(get_sound("XqaJ2Ol5cC4").astype(np.float32))
     cut = data.shape[0] * train_percentage // 100
     self.pre = Normalize()
     self.pre.fit(data)
     self.train_data = self.pre.cmp(data[:cut])
     self.valid_data = self.pre.cmp(data[cut:])
     self.batch_dim = batch_dim
     self.n_batch = 0
     self.train_max = self.train_data.shape[0] - batch_dim[
         0] - batch_dim[1] * batch_dim[2] - 1
     self.starts = np.arange(0, self.train_max - batch_dim[2], batch_dim[0])
     np.random.shuffle(self.starts)
Beispiel #2
0
    def __init__(self,
                 name,
                 batch_dim,
                 preprocess=Normalize(),
                 rate=16000,
                 n_valid=128):
        self.name = name
        self.batch_dim = batch_dim
        self.preprocess = preprocess
        self.rate = rate
        self.n_valid = n_valid
        self.valid_len = (batch_dim[0] + 1) * batch_dim[2] * n_valid

        self.sound = sound_cut(get_sound(name).astype(config.floatX))
        self.time = self.sound.shape[0] / float(rate)
        self.preprocess.fit(self.sound[:-self.valid_len])

        self.train = self.preprocess.cmp(self.sound[:-self.valid_len])
        self.valid = self.preprocess.cmp(self.sound[-self.valid_len:])

        self.n_batch = 0