class LibriSequence: def __init__(self): self.path = config.path self.specpath = config.specpath self.ls = LibriSpeech() self.ls.load() self.batchsize = 128 def sequence(self, type="train"): array = self.ls.info[type][::-1] def get(ix): reader,book,i = array[ix] file = self.ls.data[reader][book][i] buf, _ = sf.read(join(self.path, file['path'])) trans = file['trans'] wb = whole_buffer() wb.params.spectrum_range = config.librispeech_range return trans, wb.all(buf) def get2(ix): reader,book,i = array[ix] file = self.ls.data[reader][book][i] path = file['path'] if path.endswith(".flac"): path = path[:-5] + ".npy" buf = numpy.load(join(self.specpath, path)).astype(numpy.float32)/4096 return file['trans'], buf return SequenceFromLibriSpeech(array, self.batchsize, get2)
def _random_test_buf(): ls = LibriSpeech() ls.load() file = ls.uniform_test() trans = file['trans'] fn = join(config.path, file['path']) buf = _buf_from_file(fn) buf = _buffer_block([buf]) return trans, buf
def convert_all_flac(): path = config.path dest = "../speechify_dat/spectrogram" ls = LibriSpeech() ls.load() f = FilesToSpectrogram() for reader, r_ in ls.data.items(): mkdir(dest, reader) for book, b_ in r_.items(): mkdir(dest, reader, book) for i, file in enumerate(b_): npzf = join(dest, reader, book, "%s-%s-%04d.npy" % (reader, book, i)) print("Creating %s" % npzf) f.write_out_spectrogram(npzf, join(path, file['path']))
class Sampler: def __init__(self, home=False): self.path = config.path self.ls = LibriSpeech() self.ls.load() self.wb = whole_buffer() self.wb.params.spectrum_range = config.librispeech_range def rand(self): file = self.ls.uniform_train() #file = self.ls.uniform_random() buf, _ = sf.read(join(self.path, file['path'])) return file, self.wb.all(buf) def whatev(self): pass
class LibriSequence: def __init__(self): self.path = config.path self.ls = LibriSpeech() self.ls.load() self.batchsize = 4 def sequence(self, type="train"): def get(ix): reader,book,i = self.ls.info[type][ix] file = self.ls.data[reader][book][i] buf, _ = sf.read(join(self.path, file['path'])) trans = file['trans'] wb = whole_buffer() wb.params.spectrum_range = config.librispeech_range return trans, wb.all(buf) return SequenceFromLibriSpeech(self.ls.info[type], self.batchsize, get)
def __init__(self, home=False): self.path = config.path self.ls = LibriSpeech() self.ls.load() self.wb = whole_buffer() self.wb.params.spectrum_range = config.librispeech_range
from util.data import LibriSpeech ls = LibriSpeech() ls.make("../speechify_dat/combined") ls.train_test_split() ls.dump()
def __init__(self): self.path = config.path self.ls = LibriSpeech() self.ls.load() self.batchsize = 4