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


Python text.sequence_to_text方法代碼示例

本文整理匯總了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) 
開發者ID:hccho2,項目名稱:Tacotron-Wavenet-Vocoder-Korean,代碼行數:18,代碼來源:train_tacotron.py

示例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' 
開發者ID:yanggeng1995,項目名稱:vae_tacotron,代碼行數:7,代碼來源:text_test.py

示例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' 
開發者ID:youssefsharief,項目名稱:arabic-tacotron-tts,代碼行數:17,代碼來源:text_test.py

示例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 
開發者ID:hccho2,項目名稱:Tacotron-Wavenet-Vocoder-Korean,代碼行數:16,代碼來源:train_tacotron.py


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