testtts.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import pyttsx3
  2. import rpyc
  3. import random
  4. import time
  5. #conn = rpyc.classic.connect("192.168.1.110",18812)
  6. conn = rpyc.classic.connect("192.168.192.134",18812)
  7. ros = conn.modules.os
  8. rsys = conn.modules.sys
  9. engine = pyttsx3.init()
  10. #engine.say("I will speak this text")
  11. #engine.save_to_file("中文測試,我會講中文", 'test.mp3')
  12. engine.setProperty('rate',175)
  13. #engine.save_to_file("你好,我是,集仕多股份有限公司,開發的,人工智慧主播。", 'test.mp3')
  14. engine.save_to_file("我們和幸福空間合作,全自動的方式,產生人工智慧影片。集仕多股份有限公司團隊製作。", 'test.mp3')
  15. engine.runAndWait()
  16. fr=open('test.mp3','rb')
  17. fw=conn.builtins.open('/tmp/ok2.mp3','wb')
  18. while True:
  19. b=fr.read(1024)
  20. if b:
  21. fw.write(b)
  22. else:
  23. break
  24. fr.close()
  25. fw.close()
  26. val=random.randint(1000000,9999999)
  27. ros.chdir('/home/jared/Wav2Lip-master')
  28. ros.system('./proc.sh '+str(val)+' &')
  29. while True:
  30. print('waiting...')
  31. if ros.path.exists('/tmp/results/'+str(val)):
  32. break
  33. time.sleep(5)
  34. print('waiting...')
  35. ros.system('cp /home/jared/Wav2Lip-master/results/result_voice.mp4 /tmp')
  36. ros.chdir('/home/jared/tests/libopenshot')
  37. ros.system('python3 jaredtest.py')
  38. ros.system('cp /tmp/out.mp4 /var/www/html/out.mp4')
  39. ros.system('telegram-send "video is ready, http://139.162.121.30:54321/out.mp4"')
  40. #fr=conn.builtins.open('/home/jared/Wav2Lip-master/results/result_voice.mp4','rb')
  41. fr=conn.builtins.open('/tmp/out.mp4','rb')
  42. fw=open('result.mp4','wb')
  43. while True:
  44. b=fr.read(1024)
  45. if b:
  46. fw.write(b)
  47. else:
  48. break
  49. fr.close()
  50. fw.close()