import zhtts
import celery
import string
import random
# export CUDA_VISIBLE_DEVICES=0 ; python3.7 train.py -content /tmp/demo.wav -style input/girl52.wav
#py -3.7 save_mel.py --face a1.mp4 --audio eng1.mp3 --checkpoint_path wav2lip_gan.pth
#export CUDA_VISIBLE_DEVICES=0 ; python3.7 save_mel.py --face nina.mp4 --audio /tmp/demo.wav --checkpoint_path wav2lip_gan.pth
from celery import Celery

app = Celery('tasks', broker='redis://db.ptt.cx/0')

@app.task
def to_wav(txt):
    letters = string.digits
    rstr= ''.join(random.choice(letters) for i in range(10))
    #text2mel_name="TACOTRON"
    tts = zhtts.TTS() # use fastspeech2 by default
    #tts = zhtts.TTS(text2mel_name="TACOTRON") # use fastspeech2 by default

    tts.text2wav(txt, "/var/wav/"+rstr+".wav")
    return rstr
