瀏覽代碼

ming add zhtts

ming 3 年之前
父節點
當前提交
15be69d65d
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      main.py

+ 4 - 5
main.py

@@ -3,7 +3,7 @@ import openshot
 from os import listdir
 from os import listdir
 from os.path import isfile, isdir, join
 from os.path import isfile, isdir, join
 import threading
 import threading
-from gtts import gTTS 
+import zhtts
 import os 
 import os 
 import urllib
 import urllib
 from typing import List
 from typing import List
@@ -22,7 +22,7 @@ import re
 import urllib.request
 import urllib.request
 from fastapi.responses import FileResponse
 from fastapi.responses import FileResponse
 #service nginx restart
 #service nginx restart
-#
+#uvicorn main:app --host="0.0.0.0" --reload --port 8888
 
 
 
 
 app = FastAPI()
 app = FastAPI()
@@ -121,9 +121,8 @@ def make_video(name, text_content, image_urls):
     text_file.close()
     text_file.close()
     print("text file made")
     print("text file made")
     #make mp3
     #make mp3
-    language = 'zh-tw'
-    output = gTTS(text=text_content, lang=language, slow=False)
-    output.save(dir_sound+name+".mp3")
+    tts = zhtts.TTS() 
+    tts.text2wav(text_content,dir_sound+name+".mp3")
     print("mp3 file made")
     print("mp3 file made")
     #make vido
     #make vido
     t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)
     t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)