zhtest.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import celery
  2. import string
  3. import random
  4. import os
  5. # export CUDA_VISIBLE_DEVICES=0 ; python3.7 train.py -content /tmp/demo.wav -style input/girl52.wav
  6. #py -3.7 save_mel.py --face a1.mp4 --audio eng1.mp3 --checkpoint_path wav2lip_gan.pth
  7. #export CUDA_VISIBLE_DEVICES=0 ; python3.7 save_mel.py --face nina.mp4 --audio /tmp/demo.wav --checkpoint_path wav2lip_gan.pth
  8. from celery import Celery
  9. app = Celery('tasks', broker='redis://db.ptt.cx/0')
  10. @app.task
  11. def full_task(datadict):
  12. content=datadict['content']
  13. title=datadict['title']
  14. bg1=datadict['bg1']
  15. import zhtts
  16. tts = zhtts.TTS()
  17. #tts = zhtts.TTS(text2mel_name="TACOTRON") # use fastspeech2 by default
  18. tts.text2wav(content, "/var/wav/full.wav")
  19. os.chdir('/root/src/CMM_API/tests')
  20. os.system('python3 fonttest.py '+title)
  21. os.system('curl -o /var/txt/tmp.jpg '+bg1)
  22. os.system('convert /var/txt/tmp.jpg -resize 1050x1050 /var/txt/bg1.jpg')
  23. os.chdir('/home/jared/to_video')
  24. os.system('export CUDA_VISIBLE_DEVICES=0 ; python3.7 save_mel.py --face nina-no-ges.mp4 --audio /var/wav/full.wav --outfile /var/video/full.mp4 --checkpoint_path gan.pth')
  25. #text2mel_name="TACOTRON"
  26. os.chdir('/root/src/CMM_API/tests')
  27. os.system('python3 openshottest.py')
  28. return "ok"
  29. @app.task
  30. def to_video(fname):
  31. os.chdir('/home/jared/to_video')
  32. os.system('export CUDA_VISIBLE_DEVICES=0 ; python3.7 save_mel.py --face nina-no-ges.mp4 --audio /var/wav/'+fname+'.wav --outfile /var/video/'+fname+'.mp4 --checkpoint_path gan.pth')
  33. #text2mel_name="TACOTRON"
  34. return "ok"
  35. @app.task
  36. def to_wav(txt):
  37. import zhtts
  38. letters = string.digits
  39. rstr= ''.join(random.choice(letters) for i in range(10))
  40. #text2mel_name="TACOTRON"
  41. tts = zhtts.TTS() # use fastspeech2 by default
  42. #tts = zhtts.TTS(text2mel_name="TACOTRON") # use fastspeech2 by default
  43. tts.text2wav(txt, "/var/wav/"+rstr+".wav")
  44. return rstr