meldir=str(config_manager.train_datadir / 'mels'), num_samples=config['n_samples']) # (phonemes, mel) val_samples, _ = load_files( metafile=str(config_manager.train_datadir / 'test_metafile.txt'), meldir=str(config_manager.train_datadir / 'mels'), num_samples=config['n_samples']) # (phonemes, text, mel) # get model, prepare data for model, create datasets model = config_manager.get_model() config_manager.compile_model(model) data_prep = DataPrepper(config=config, tokenizer=model.text_pipeline.tokenizer) test_list = [data_prep(s) for s in val_samples] train_dataset = Dataset(samples=train_samples, preprocessor=data_prep, batch_size=config['batch_size'], mel_channels=config['mel_channels'], shuffle=True) val_dataset = Dataset(samples=val_samples, preprocessor=data_prep, batch_size=config['batch_size'], mel_channels=config['mel_channels'], shuffle=False) # create logger and checkpointer and restore latest model summary_manager = SummaryManager(model=model, log_dir=config_manager.log_dir, config=config) checkpoint = tf.train.Checkpoint(step=tf.Variable(1), optimizer=model.optimizer,
metafile=str(train_meta), meldir=str(meldir), num_samples=config['n_samples']) # (phonemes, mel) val_samples, _ = load_files( metafile=str(test_meta), meldir=str(meldir), num_samples=config['n_samples']) # (phonemes, text, mel) # get model, prepare data for model, create datasets data_prep = DataPrepper(config=config, tokenizer=model.text_pipeline.tokenizer) script_batch_size = 5 * config['batch_size'] # faster parallel computation train_dataset = Dataset(samples=train_samples, preprocessor=data_prep, batch_size=script_batch_size, shuffle=False, drop_remainder=False) val_dataset = Dataset(samples=val_samples, preprocessor=data_prep, batch_size=script_batch_size, shuffle=False, drop_remainder=False) if model.r != 1: print( f"ERROR: model's reduction factor is greater than 1, check config. (r={model.r}" ) # identify last decoder block n_layers = len(config_manager.config['decoder_num_heads']) n_dense = int(config_manager.config['decoder_dense_blocks']) n_convs = int(n_layers - n_dense)
config_manager = ConfigManager(config_path=args.config, model_kind='forward', session_name=args.session_name) config = config_manager.config config_manager.create_remove_dirs(clear_dir=args.clear_dir, clear_logs=args.clear_logs, clear_weights=args.clear_weights) config_manager.dump_config() config_manager.print_config() train_data_list = build_file_list(config_manager.train_datadir / 'forward_data/train') dataprep = ForwardDataPrepper() train_dataset = Dataset(samples=train_data_list, mel_channels=config['mel_channels'], preprocessor=dataprep, batch_size=config['batch_size'], shuffle=True) val_data_list = build_file_list(config_manager.train_datadir / 'forward_data/val') val_dataset = Dataset(samples=val_data_list, mel_channels=config['mel_channels'], preprocessor=dataprep, batch_size=config['batch_size'], shuffle=False) # get model, prepare data for model, create datasets model = config_manager.get_model() config_manager.compile_model(model) # create logger and checkpointer and restore latest model