Python text.sequence_to_text() Examples

The following are 7 code examples of text.sequence_to_text(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module text , or try the search function .
Example #1
Source File: train_tacotron.py    From Tacotron-Wavenet-Vocoder-Korean with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: train_tacotron2.py    From Tacotron2-Wavenet-Korean-TTS with MIT License 6 votes vote down vote up
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) 
Example #3
Source File: text_test.py    From vae_tacotron with MIT License 5 votes vote down vote up
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' 
Example #4
Source File: text_test.py    From libfaceid with MIT License 5 votes vote down vote up
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' 
Example #5
Source File: text_test.py    From arabic-tacotron-tts with MIT License 5 votes vote down vote up
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' 
Example #6
Source File: train_tacotron.py    From Tacotron-Wavenet-Vocoder-Korean with MIT License 5 votes vote down vote up
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 
Example #7
Source File: text_test.py    From tacotron with MIT License 5 votes vote down vote up
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'