ZhTTS
A demo of zh/Chinese Text to Speech system run on CPU in real time. (fastspeech2 + mbmelgan)
RTF(real time factor): 0.2 with cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 24khz audio use fastspeech2, RTF1.6 for tacotron2
This repo is mainly based on TensorFlowTTS with little improvement.
- tflite model come from colab, thx to @azraelkuan
- add pause at punctuation
- add TN (Text Normalization) from chinese_text_normalization
demo wav
text = "2020年,这是一个开源的端到端中文语音合成系统"
Install
pip install zhtts
or clone this repo, then pip install .
Usage
import zhtts
text = "2020年,这是一个开源的端到端中文语音合成系统"
tts = zhtts.TTS() # use fastspeech2 by default
tts.text2wav(text, "demo.wav")
>>> Save wav to demo.wav
tts.frontend(text)
>>> ('二零二零年,这是一个开源的端到端中文语音合成系统', 'sil ^ er4 #0 l ing2 #0 ^ er4 #0 l ing2 #0 n ian2 #0 #3 zh e4 #0 sh iii4 #0 ^ i2 #0 g e4 #0 k ai1 #0 ^ van2 #0 d e5 #0 d uan1 #0 d ao4 #0 d uan1 #0 zh ong1 #0 ^ uen2 #0 ^ v3 #0 ^ in1 #0 h e2 #0 ch eng2 #0 x i4 #0 t ong3 sil')
tts.synthesis(text)
>>> array([0., 0., 0., ..., 0., 0., 0.], dtype=float32)
web api demo
clone this repo, pip install flask first, then
python app.py
- visit http://localhost:5000 for tts interaction
- do HTTP GET at http://localhost:5000/api/tts?text=your%20sentence to get WAV audio back:
$ curl -o "helloworld.wav" "http://localhost:5000/api/tts?text=%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C"
%E4%BD%A0%E5%A5%BD%E4%B8%96%E7%95%8C is url code of"你好,世界!"
Use tacotron2 instead of fastspeech2
wav generate from tacotron model is better than fast speech, however tacotron is much slower , to use Tacotron, change code
import zhtts
tts = zhtts.TTS(text2mel_name="TACOTRON")
# tts = zhtts.TTS(text2mel_name="FASTSPEECH2")
Metadata
Release files for zhtts 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zhtts-0.0.1.tar.gz | 40.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zhtts-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.2 MB
Release files / zhtts-0.0.1.tar.gz
| Download URL | zhtts-0.0.1.tar.gz |
|---|---|
| Size | 40.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
442e78f6ebc9b30a285872075968b3e957f4460333a9123a38ec8d78330634e4
|
|
BLAKE2b-256 checksum How to use checksums |
8455f87bd01e4187c8e25975f5ef65bc25d1f4f5e0ef3766986a97b38edde598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10
|
Release files / zhtts-0.0.1-py3-none-any.whl
| Download URL | zhtts-0.0.1-py3-none-any.whl |
|---|---|
| Size | 40.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dad073dff12ccd55508a870f304559a6c309edaddb3536e95e2ddc79f2dab424
|
|
BLAKE2b-256 checksum How to use checksums |
7d830e1e61b3537f069fd5e943f673ab9da909ae42936beee3150654111384fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10
|