np.save(paths.quant / f'{wav_id}.npy', x, allow_pickle=False)
    return wav_id, m.shape[-1]


wav_files = get_files(path, extension)
paths = Paths(hp.data_path, hp.voc_model_id, hp.tts_model_id)

print(f'\n{len(wav_files)} {extension[1:]} files found in "{path}"\n')

if len(wav_files) == 0:

    print('Please point wav_path in hparams.py to your dataset,')
    print('or use the --path option.\n')

else:
    text_dict = ljspeech(path)
    with open(paths.data / 'text_dict.pkl', 'wb') as f:
        pickle.dump(text_dict, f)

    n_workers = max(1, args.num_workers)

    simple_table([('Sample Rate', hp.sample_rate), ('Bit Depth', hp.bits),
                  ('Mu Law', hp.mu_law), ('Hop Length', hp.hop_length),
                  ('CPU Usage', f'{n_workers}/{cpu_count()}')])

    pool = Pool(processes=n_workers)
    dataset = []

    for i, (item_id,
            length) in enumerate(pool.imap_unordered(process_wav, wav_files),
                                 1):
Example #2
0
extension = args.extension
path = args.path

if __name__ == '__main__':

    wav_files = get_files(path, extension)
    # print(path, extension)
    wav_ids = {w.stem for w in wav_files}
    paths = Paths(hp.data_path, hp.voc_model_id, hp.tts_model_id)
    # print(f'\n{len(wav_files)} {extension[1:]} files found in "{path}"')
    assert len(wav_files) > 0, f'Found no wav files in {path}, exiting.'
    # print(wav_files)
    # exit()
    if args.dt:
        print('running preproccesing for dt...')
        text_dict = ljspeech(path, dt=True)
    else:
        text_dict = ljspeech(path)
    # print(len(text_dict))
    # print(len(wav_ids))
    # for item_id, text in text_dict.items():
    #     # print(item_id)

    #     if item_id in wav_ids:
    #         # print(item_id)

    text_dict = {
        item_id: text
        for item_id, text in text_dict.items() if item_id in wav_ids
    }
    # exit()
Example #3
0
wav_files = get_files(path, extension)
paths = Paths(hp.data_path, hp.voc_model_id, hp.tts_model_id)

print(f'\n{len(wav_files)} {extension[1:]} files found in "{path}"\n')

if len(wav_files) == 0:

    print('Please point wav_path in hparams.py to your dataset,')
    print('or use the --path option.\n')

else:

    if not hp.ignore_tts:

        # text_dict = ljspeech(path)
        text_dict = ljspeech(Path(path).parent)

        with open(paths.data / 'text_dict.pkl', 'wb') as f:
            pickle.dump(text_dict, f)

    n_workers = max(1, args.num_workers)

    simple_table([('Sample Rate', hp.sample_rate), ('Bit Depth', hp.bits),
                  ('Mu Law', hp.mu_law), ('Hop Length', hp.hop_length),
                  ('CPU Usage', f'{n_workers}/{cpu_count()}')])

    pool = Pool(processes=n_workers)
    dataset = []

    for i, (item_id,
            length) in enumerate(pool.imap_unordered(process_wav, wav_files),
Example #4
0
parser.add_argument('--path', '-p', help='directly point to dataset path')
parser.add_argument('--num_workers', '-w', metavar='N', type=valid_n_workers, default=cpu_count()-1, help='The number of worker threads to use for preprocessing')
parser.add_argument('--config', metavar='FILE', default='config.yaml', help='The config containing all hyperparams.')
args = parser.parse_args()


if __name__ == '__main__':

    config = read_config(args.config)
    wav_files = get_files(args.path, '.wav')
    wav_ids = {w.stem for w in wav_files}
    paths = Paths(config['data_path'], config['voc_model_id'], config['tts_model_id'])
    print(f'\n{len(wav_files)} .wav files found in "{args.path}"')
    assert len(wav_files) > 0, f'Found no wav files in {args.path}, exiting.'

    text_dict = ljspeech(args.path)
    text_dict = {item_id: text for item_id, text in text_dict.items()
                 if item_id in wav_ids and len(text) > config['preprocessing']['min_text_len']}
    wav_files = [w for w in wav_files if w.stem in text_dict]
    print(f'Using {len(wav_files)} wav files that are indexed in metafile.\n')

    n_workers = max(1, args.num_workers)

    dsp = DSP.from_config(config)

    simple_table([
        ('Sample Rate', dsp.sample_rate),
        ('Bit Depth', dsp.bits),
        ('Mu Law', dsp.mu_law),
        ('Hop Length', dsp.hop_length),
        ('CPU Usage', f'{n_workers}/{cpu_count()}'),