Browse Source

ming add zhtts

ming 3 years ago
parent
commit
15be69d65d
1 changed files with 4 additions and 5 deletions
  1. 4 5
      main.py

+ 4 - 5
main.py

@@ -3,7 +3,7 @@ import openshot
 from os import listdir
 from os.path import isfile, isdir, join
 import threading
-from gtts import gTTS 
+import zhtts
 import os 
 import urllib
 from typing import List
@@ -22,7 +22,7 @@ import re
 import urllib.request
 from fastapi.responses import FileResponse
 #service nginx restart
-#
+#uvicorn main:app --host="0.0.0.0" --reload --port 8888
 
 
 app = FastAPI()
@@ -121,9 +121,8 @@ def make_video(name, text_content, image_urls):
     text_file.close()
     print("text file made")
     #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")
     #make vido
     t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)