Example #1
0
 def __init__(self):
     gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
     tf.config.experimental.set_visible_devices(devices=gpus[0:2], device_type='GPU')
     for gpu in gpus:
         tf.config.experimental.set_memory_growth(gpu, True)
     self._converter_model()
     self.tts_pause = TTSSegPause()
     self.tts_py = TTSPinYin()
Example #2
0
# -*- coding:utf-8 -*-

import re
import yaml
import numpy as np
import pandas as pd
from pypinyin import Style
from conf.config import config
from core.parse_text_add_pause import TTSSegPause
from core.tftts_pinyin import TTSModel

if __name__ == "__main__":
    tts_model = TTSModel()
    tts_seg_pause = TTSSegPause()
    data_pd = pd.read_csv(config.MIX_VOICE_TEXT_DATA_PATH,
                          sep=',',
                          encoding='utf-8')
    mix_voice_text_index_list = list(
        data_pd[config.MIX_VOICE_TEXT_INDEX].values)
    mix_voice_text_list = list(data_pd[config.MIX_VOICE_TEXT].values)

    f2 = "./data/010001-020000.txt"

    f1 = open("./data/000001-010000.txt")
    lines = f1.readlines()
    with open(f2, "w") as file:
        for idx in range(0, len(lines), 2):
            utt_id, chn_char = lines[idx].strip().split()
            per_text_pinyin = lines[idx + 1].strip().split()
            if "IY1" in per_text_pinyin or "B" in chn_char:
                print(f"Skip this: {utt_id} {chn_char} {per_text_pinyin}")
Example #3
0
# print("interpreter_mb_melgan:",interpreter_mb_melgan)
interpreter_mb_melgan.allocate_tensors()

# Get input and output tensors.
input_details_mb_melgan = interpreter_mb_melgan.get_input_details()
# print("input_details_mb_melgan:",input_details_mb_melgan)
output_details_mb_melgan = interpreter_mb_melgan.get_output_details()
# print("output_details_mb_melgan:",output_details_mb_melgan)

# Prepare input data.
def prepare_input(input_ids):
  return (tf.expand_dims(tf.convert_to_tensor(input_ids, dtype=tf.int32), 0),
          tf.convert_to_tensor([len(input_ids)], tf.int32),
          tf.convert_to_tensor([0], dtype=tf.int32))
  
tts_pause = TTSSegPause()
# Test the model on random input data.
def infer(input_text):
  processor = AutoProcessor.from_pretrained(pretrained_path=config_lp.baker_mapper_pretrained_path)
  input_text = tts_pause.add_pause(input_text)
  # logging.info( "[TTSModel] [do_synthesis] input_text:{}".format( input_text ) )
  input_ids = processor.text_to_sequence(input_text, inference=True) 
        
  # input_ids = np.concatenate([input_ids, [len(symbols) - 1]], -1)  # eos.
  # 
  interpreter_tacotron.resize_tensor_input(input_details_tacotron[0]['index'],  [1, len(input_ids)])
  interpreter_tacotron.allocate_tensors()
  input_data = prepare_input(input_ids)
  for i, detail in enumerate(input_details_tacotron):
    print(detail)
    input_shape = detail['shape']