Bläddra i källkod

fix lang problem

ming 3 år sedan
förälder
incheckning
10254d490e
1 ändrade filer med 6 tillägg och 6 borttagningar
  1. 6 6
      OpenshotService/openshot_video_generator.py

+ 6 - 6
OpenshotService/openshot_video_generator.py

@@ -157,7 +157,7 @@ def file_prepare(name, name_hash,text_content,image_urls,lang='zh'):
     language = 'zh-tw'
     txt_idx = 0
     for txt in text_content:
-        if lang==1:
+        if lang!='zh':
             tts = gTTS(txt)
             tts.save(dir_sound+name_hash+"/"+str(txt_idx)+".mp3")
         else:
@@ -167,14 +167,14 @@ def file_prepare(name, name_hash,text_content,image_urls,lang='zh'):
     print("mp3 file made")
     #make title as image
     txt2image_title(name, dir_title+name_hash+".png",lang)
-
+    
 def txt2image(content, save_target,lang='zh'):
     unicode_text = trim_punctuation(content)
     font = ''
     if lang=='zh':
         font = ImageFont.truetype(font="font/DFT_B7.ttc", size=38)
     else :
-        font = ImageFont.load("arial.pil")
+        font = ImageFont.truetype(font="font/arial.ttf", size=38)
     text_width, text_height = font.getsize(unicode_text)
     canvas = Image.new('RGBA', (700, 500), (255, 0, 0, 0) )
     draw = ImageDraw.Draw(canvas)
@@ -186,9 +186,9 @@ def txt2image_title(content, save_target, lang='zh'):
     unicode_text = trim_punctuation(content)
     font = ''
     if lang=='zh':
-        font = ImageFont.truetype(font="font/DFT_B7.ttc", size=38)
+        font = ImageFont.truetype(font="font/DFT_B7.ttc", size=22)
     else :
-        font = ImageFont.load("arial.pil")
+        font = ImageFont.truetype(font="font/arial.ttf", size=22)
     text_width, text_height = font.getsize(unicode_text)
     canvas = Image.new('RGBA', (510, 500), (255, 0, 0, 0) )
     draw = ImageDraw.Draw(canvas)
@@ -276,7 +276,7 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,avatar):
     """ 影片產生主程式。 """
     print(os.getcwd())
     print('sub image made')
-    file_prepare(name, name_hash, text_content,image_urls,0)
+    file_prepare(name, name_hash, text_content,image_urls)
     sub_list=generate_subtitle_image(name_hash,text_content)
     
     for fname in range(len(text_content)):