本文整理汇总了Python中text.sequence_to_text方法的典型用法代码示例。如果您正苦于以下问题:Python text.sequence_to_text方法的具体用法?Python text.sequence_to_text怎么用?Python text.sequence_to_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text
的用法示例。
在下文中一共展示了text.sequence_to_text方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_and_plot_fn
# 需要导入模块: import text [as 别名]
# 或者: from text import sequence_to_text [as 别名]
def save_and_plot_fn(args, log_dir, step, loss, prefix):
idx, (seq, spec, align) = args
audio_path = os.path.join(log_dir, '{}-step-{:09d}-audio{:03d}.wav'.format(prefix, step, idx))
align_path = os.path.join(log_dir, '{}-step-{:09d}-align{:03d}.png'.format(prefix, step, idx))
waveform = inv_spectrogram(spec.T,hparams)
save_wav(waveform, audio_path,hparams.sample_rate)
info_text = 'step={:d}, loss={:.5f}'.format(step, loss)
if 'korean_cleaners' in [x.strip() for x in hparams.cleaners.split(',')]:
log('Training korean : Use jamo')
plot.plot_alignment( align, align_path, info=info_text, text=sequence_to_text(seq,skip_eos_and_pad=True, combine_jamo=True), isKorean=True)
else:
log('Training non-korean : X use jamo')
plot.plot_alignment(align, align_path, info=info_text,text=sequence_to_text(seq,skip_eos_and_pad=True, combine_jamo=False), isKorean=False)
示例2: test_sequence_to_text
# 需要导入模块: import text [as 别名]
# 或者: from text import sequence_to_text [as 别名]
def test_sequence_to_text():
assert sequence_to_text([]) == ''
assert sequence_to_text([1]) == '~'
assert sequence_to_text([9, 36, 54, 1]) == 'Hi!~'
assert sequence_to_text([2, 64, 83, 132, 64, 3]) == 'A {AW1 S} B'
示例3: test_text_to_sequence
# 需要导入模块: import text [as 别名]
# 或者: from text import sequence_to_text [as 别名]
def test_text_to_sequence():
assert text_to_sequence('', []) == [1]
assert text_to_sequence('{t a s d ii0 d a t i1 n}', []) == [49, 29, 48, 32, 38, 32, 29, 49, 37, 44, 1]
assert text_to_sequence('{t a s d ii0 d a t i1 n} {s t a E S A t}', ['lowercase']) == [49, 29, 48, 32, 38, 32, 29, 49, 37, 44, 11, 48, 49, 29, 18, 22, 15, 49, 1]
assert text_to_sequence('{t a s d ii0 d a t i1 n} {s t a E S A t}', ['english_cleaners']) == [49, 29, 48, 32, 38, 32, 29, 49, 37, 44, 11, 48, 49, 29, 18, 22, 15, 49, 1]
assert text_to_sequence('{t a s d ii0 d a t i1 n} {s t a E S A t}', ['arabic_cleaners']) == [49, 29, 48, 32, 38, 32, 29, 49, 37, 44, 11, 48, 49, 29, 18, 22, 15, 49, 1]
# assert text_to_sequence('Hi', ['lowercase']) == [35, 36, 1]
# assert text_to_sequence('A {AW1 S} B', ['english_cleaners']) == [28, 64, 83, 132, 64, 29, 1]
# def test_sequence_to_text():
# assert sequence_to_text([]) == ''
# assert sequence_to_text([1]) == '~'
# assert sequence_to_text([9, 36, 54, 1]) == 'Hi!~'
# assert sequence_to_text([2, 64, 83, 132, 64, 3]) == 'A {AW1 S} B'
示例4: create_batch_inputs_from_texts
# 需要导入模块: import text [as 别名]
# 或者: from text import sequence_to_text [as 别名]
def create_batch_inputs_from_texts(texts):
sequences = [text_to_sequence(text) for text in texts]
inputs = _prepare_inputs(sequences)
input_lengths = np.asarray([len(x) for x in inputs], dtype=np.int32)
for idx, (seq, text) in enumerate(zip(inputs, texts)):
recovered_text = sequence_to_text(seq, skip_eos_and_pad=True)
if recovered_text != h2j(text):
log(" [{}] {}".format(idx, text))
log(" [{}] {}".format(idx, recovered_text))
log("="*30)
return inputs, input_lengths