Views
No views yet
pip install TensorFlowTTS1import numpy as np
2import soundfile as sf
3import yaml
4
5import tensorflow as tf
6
7from tensorflow_tts.inference import AutoProcessor
8from tensorflow_tts.inference import TFAutoModel
9
10processor = AutoProcessor.from_pretrained("tensorspeech/tts-fastspeech2-baker-ch")
11fastspeech2 = TFAutoModel.from_pretrained("tensorspeech/tts-fastspeech2-baker-ch")
12
13text = "这是一个开源的端到端中文语音合成系统"
14
15input_ids = processor.text_to_sequence(text, inference=True)
16
17mel_before, mel_after, duration_outputs, _, _ = fastspeech2.inference(
18 input_ids=tf.expand_dims(tf.convert_to_tensor(input_ids, dtype=tf.int32), 0),
19 speaker_ids=tf.convert_to_tensor([0], dtype=tf.int32),
20 speed_ratios=tf.convert_to_tensor([1.0], dtype=tf.float32),
21 f0_ratios =tf.convert_to_tensor([1.0], dtype=tf.float32),
22 energy_ratios =tf.convert_to_tensor([1.0], dtype=tf.float32),
23)@misc{ren2021fastspeech,
title={FastSpeech 2: Fast and High-Quality End-to-End Text to Speech},
author={Yi Ren and Chenxu Hu and Xu Tan and Tao Qin and Sheng Zhao and Zhou Zhao and Tie-Yan Liu},
year={2021},
eprint={2006.04558},
archivePrefix={arXiv},
primaryClass={eess.AS}
}@misc{TFTTS,
author = {Minh Nguyen, Alejandro Miguel Velasquez, Erogol, Kuan Chen, Dawid Kobus, Takuya Ebata,
Trinh Le and Yunchao He},
title = {TensorflowTTS},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\\url{https://github.com/TensorSpeech/TensorFlowTTS}},
}