import pyttsx3 import rpyc import random import time import sys import codecs engine = pyttsx3.init() #engine.say("I will speak this text") #engine.save_to_file("中文測試,我會講中文", 'test.mp3') engine.setProperty('rate',175) fr=codecs.open('/tmp/script.txt','r','u-tf8') lines=fr.readlines() fr.close() engine.say("你好,我是,集仕多股份有限公司,開發的,人工智慧主播,這是一個測試影片。我們與幸福空間合作,只要給我們影片的腳本文字檔案,我們立刻可以產生影片。", 'test.mp3') engine.runAndWait() sys.exit() fr=open('test.mp3','rb') fw=conn.builtins.open('/tmp/ok2.mp3','wb') while True: b=fr.read(1024) if b: fw.write(b) else: break fr.close() fw.close() val=random.randint(1000000,9999999) ros.chdir('/home/jared/Wav2Lip-master') ros.system('./proc.sh '+str(val)+' &') while True: print('waiting...') if ros.path.exists('/tmp/results/'+str(val)): break time.sleep(5) print('waiting...') fr=conn.builtins.open('/home/jared/Wav2Lip-master/results/result_voice.mp4','rb') fw=open('result.mp4','wb') while True: b=fr.read(1024) if b: fw.write(b) else: break fr.close() fw.close()