當前位置: 首頁>>代碼示例>>Python>>正文


Python hparams.sentences方法代碼示例

本文整理匯總了Python中hparams.hparams.sentences方法的典型用法代碼示例。如果您正苦於以下問題:Python hparams.sentences方法的具體用法?Python hparams.sentences怎麽用?Python hparams.sentences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hparams.hparams的用法示例。


在下文中一共展示了hparams.sentences方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_eval

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def run_eval(args, checkpoint_path, output_dir):
	print(hparams_debug_string())
	synth = Synthesizer()
	synth.load(checkpoint_path)
	eval_dir = os.path.join(output_dir, 'eval')
	log_dir = os.path.join(output_dir, 'logs-eval')
	wav = load_wav(args.reference_audio)
	reference_mel = melspectrogram(wav).transpose()
	#Create output path if it doesn't exist
	os.makedirs(eval_dir, exist_ok=True)
	os.makedirs(log_dir, exist_ok=True)
	os.makedirs(os.path.join(log_dir, 'wavs'), exist_ok=True)
	os.makedirs(os.path.join(log_dir, 'plots'), exist_ok=True)

	with open(os.path.join(eval_dir, 'map.txt'), 'w') as file:
		for i, text in enumerate(tqdm(hparams.sentences)):
			start = time.time()
			mel_filename = synth.synthesize(text, i+1, eval_dir, log_dir, None, reference_mel)

			file.write('{}|{}\n'.format(text, mel_filename))
	print('synthesized mel spectrograms at {}'.format(eval_dir)) 
開發者ID:rishikksh20,項目名稱:vae_tacotron2,代碼行數:23,代碼來源:synthesize.py

示例2: get_sentences

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def get_sentences(args):
	if args.text_list != '':
		with open(args.text_list, 'rb') as f:
			sentences = list(map(lambda l: l.decode("utf-8")[:-1], f.readlines()))
	else:
		sentences = hparams.sentences
	return sentences 
開發者ID:Rayhane-mamah,項目名稱:Tacotron-2,代碼行數:9,代碼來源:synthesize.py

示例3: synthesize

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def synthesize(args, hparams, taco_checkpoint, wave_checkpoint, sentences):
	log('Running End-to-End TTS Evaluation. Model: {}'.format(args.name or args.model))
	log('Synthesizing mel-spectrograms from text..')
	wavenet_in_dir = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
	#Delete Tacotron model from graph
	tf.reset_default_graph()
	#Sleep 1/2 second to let previous graph close and avoid error messages while Wavenet is synthesizing
	sleep(0.5)
	log('Synthesizing audio from mel-spectrograms.. (This may take a while)')
	wavenet_synthesize(args, hparams, wave_checkpoint)
	log('Tacotron-2 TTS synthesis complete!') 
開發者ID:Rayhane-mamah,項目名稱:Tacotron-2,代碼行數:13,代碼來源:synthesize.py

示例4: main

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def main():
	accepted_modes = ['eval', 'synthesis', 'live']
	parser = argparse.ArgumentParser()
	parser.add_argument('--checkpoint', default='pretrained/', help='Path to model checkpoint')
	parser.add_argument('--hparams', default='',
		help='Hyperparameter overrides as a comma-separated list of name=value pairs')
	parser.add_argument('--name', help='Name of logging directory if the two models were trained together.')
	parser.add_argument('--tacotron_name', help='Name of logging directory of Tacotron. If trained separately')
	parser.add_argument('--wavenet_name', help='Name of logging directory of WaveNet. If trained separately')
	parser.add_argument('--model', default='Tacotron')
	parser.add_argument('--input_dir', default='training_data/', help='folder to contain inputs sentences/targets')
	parser.add_argument('--mels_dir', default='tacotron_output/eval/', help='folder to contain mels to synthesize audio from using the Wavenet')
	parser.add_argument('--output_dir', default='output/', help='folder to contain synthesized mel spectrograms')
	parser.add_argument('--mode', default='eval', help='mode of run: can be one of {}'.format(accepted_modes))
	parser.add_argument('--GTA', default='True', help='Ground truth aligned synthesis, defaults to True, only considered in synthesis mode')
	parser.add_argument('--text_list', default='', help='Text file contains list of texts to be synthesized. Valid if mode=eval')
	parser.add_argument('--speaker_id', default=None, help='Defines the speakers ids to use when running standalone Wavenet on a folder of mels. this variable must be a comma-separated list of ids')
	args = parser.parse_args()

	if args.mode not in accepted_modes:
		raise ValueError('accepted modes are: {}, found {}'.format(accepted_modes, args.mode))

	if args.GTA not in ('True', 'False'):
		raise ValueError('GTA option must be either True or False')

	taco_checkpoint, wave_checkpoint, hparams = prepare_run(args)
	sentences = get_sentences(args)

	tacotron_synthesize(args, hparams, taco_checkpoint, sentences) 
開發者ID:Joee1995,項目名稱:tacotron2-mandarin-griffin-lim,代碼行數:31,代碼來源:synthesize.py

示例5: get_sentences

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def get_sentences(args):
    if args.text_list != '':
        with open(args.text_list, 'rb') as f:
            sentences = list(map(lambda l: l.decode("utf-8")[:-1], f.readlines()))
    else:
        sentences = hparams.sentences
    return sentences 
開發者ID:cnlinxi,項目名稱:style-token_tacotron2,代碼行數:9,代碼來源:interval_synthesis.py

示例6: synthesize

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def synthesize(args, hparams, taco_checkpoint, wave_checkpoint, sentences):
    log('Running End-to-End TTS Evaluation. Model: {}'.format(args.name or args.model))
    log('Synthesizing mel-spectrograms from text..')
    wavenet_in_dir = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
    # Delete Tacotron model from graph
    tf.reset_default_graph()
    # Sleep 1/2 second to let previous graph close and avoid error messages while Wavenet is synthesizing
    sleep(0.5)
    log('Synthesizing audio from mel-spectrograms.. (This may take a while)')
    # wavenet_synthesize(args, hparams, wave_checkpoint)
    log('Tacotron-2 TTS synthesis complete!') 
開發者ID:cnlinxi,項目名稱:style-token_tacotron2,代碼行數:13,代碼來源:interval_synthesis.py

示例7: main

# 需要導入模塊: from hparams import hparams [as 別名]
# 或者: from hparams.hparams import sentences [as 別名]
def main():
	accepted_modes = ['eval', 'synthesis', 'live']
	parser = argparse.ArgumentParser()
	parser.add_argument('--checkpoint', default='pretrained/', help='Path to model checkpoint')
	parser.add_argument('--hparams', default='',
		help='Hyperparameter overrides as a comma-separated list of name=value pairs')
	parser.add_argument('--name', help='Name of logging directory if the two models were trained together.')
	parser.add_argument('--tacotron_name', help='Name of logging directory of Tacotron. If trained separately')
	parser.add_argument('--wavenet_name', help='Name of logging directory of WaveNet. If trained separately')
	parser.add_argument('--model', default='Tacotron-2')
	parser.add_argument('--input_dir', default='training_data/', help='folder to contain inputs sentences/targets')
	parser.add_argument('--mels_dir', default='tacotron_output/eval/', help='folder to contain mels to synthesize audio from using the Wavenet')
	parser.add_argument('--output_dir', default='output/', help='folder to contain synthesized mel spectrograms')
	parser.add_argument('--mode', default='eval', help='mode of run: can be one of {}'.format(accepted_modes))
	parser.add_argument('--GTA', default='True', help='Ground truth aligned synthesis, defaults to True, only considered in synthesis mode')
	parser.add_argument('--text_list', default='', help='Text file contains list of texts to be synthesized. Valid if mode=eval')
	parser.add_argument('--speaker_id', default=None, help='Defines the speakers ids to use when running standalone Wavenet on a folder of mels. this variable must be a comma-separated list of ids')
	args = parser.parse_args()

	accepted_models = ['Tacotron', 'WaveNet', 'Tacotron-2']

	if args.model not in accepted_models:
		raise ValueError('please enter a valid model to synthesize with: {}'.format(accepted_models))

	if args.mode not in accepted_modes:
		raise ValueError('accepted modes are: {}, found {}'.format(accepted_modes, args.mode))

	if args.mode == 'live' and args.model == 'Wavenet':
		raise RuntimeError('Wavenet vocoder cannot be tested live due to its slow generation. Live only works with Tacotron!')

	if args.GTA not in ('True', 'False'):
		raise ValueError('GTA option must be either True or False')

	if args.model == 'Tacotron-2':
		if args.mode == 'live':
			warn('Requested a live evaluation with Tacotron-2, Wavenet will not be used!')
		if args.mode == 'synthesis':
			raise ValueError('I don\'t recommend running WaveNet on entire dataset.. The world might end before the synthesis :) (only eval allowed)')

	taco_checkpoint, wave_checkpoint, hparams = prepare_run(args)
	sentences = get_sentences(args)

	if args.model == 'Tacotron':
		_ = tacotron_synthesize(args, hparams, taco_checkpoint, sentences)
	elif args.model == 'WaveNet':
		wavenet_synthesize(args, hparams, wave_checkpoint)
	elif args.model == 'Tacotron-2':
		synthesize(args, hparams, taco_checkpoint, wave_checkpoint, sentences)
	else:
		raise ValueError('Model provided {} unknown! {}'.format(args.model, accepted_models)) 
開發者ID:Rayhane-mamah,項目名稱:Tacotron-2,代碼行數:52,代碼來源:synthesize.py


注:本文中的hparams.hparams.sentences方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。