ming 3 лет назад
Родитель
Сommit
41571fe99c
2 измененных файлов с 12 добавлено и 25 удалено
  1. 9 18
      OpenshotService/openshot_video_generator.py
  2. 3 7
      api/main.py

+ 9 - 18
OpenshotService/openshot_video_generator.py

@@ -125,19 +125,7 @@ def make_dir(name_hash):
     except FileExistsError:
     except FileExistsError:
         print("~~~~~~Warning~~~~~~~~~Directory " , dir_subtitle+name_hash ,  " already exists")
         print("~~~~~~Warning~~~~~~~~~Directory " , dir_subtitle+name_hash ,  " already exists")
 
 
-def Check_text_content(text_content):
-    mulitLang = 0
-    status = False
-    for txt in text_content:
-        if re.search('[a-zA-Z]', txt) !=None:
-            mulitLang = 1
-        if re.search(',', txt) !=None:
-            print('包含非法符號')
-            status = {'msg':{'eng':'symbol "," is not allowede','zh':'輸入不能含有","符號'}}
-    return mulitLang, status
-
-def file_prepare(name, name_hash,text_content,image_urls):
-    mulitLang, status = Check_text_content(text_content)
+def file_prepare(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
     make_dir(name_hash)
     make_dir(name_hash)
     img_num = 1
     img_num = 1
     for imgu in image_urls:
     for imgu in image_urls:
@@ -164,9 +152,13 @@ def file_prepare(name, name_hash,text_content,image_urls):
     #make mp3
     #make mp3
     txt_idx = 0
     txt_idx = 0
     for txt in text_content:
     for txt in text_content:
-        if multiLang==1:
-            tts = gTTS(txt,lang='zh-tw')
-            tts.save(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
+        if lang!='zh' or multiLang==1:
+            if lang!='zh':
+                tts = gTTS(txt)
+                tts.save(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
+            else:
+                tts = gTTS(txt,lang='zh-tw')
+                tts.save(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
             #speed up 
             #speed up 
             ff = ffmpy.FFmpeg(inputs={dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3": None}
             ff = ffmpy.FFmpeg(inputs={dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3": None}
                             , outputs={dir_sound+name_hash+"/"+str(txt_idx)+".mp3": ["-filter:a", "atempo=1.2"]})
                             , outputs={dir_sound+name_hash+"/"+str(txt_idx)+".mp3": ["-filter:a", "atempo=1.2"]})
@@ -179,7 +171,7 @@ def file_prepare(name, name_hash,text_content,image_urls):
         txt_idx+=1
         txt_idx+=1
     print("mp3 file made")
     print("mp3 file made")
     #make title as image
     #make title as image
-    txt2image_title(name, dir_title+name_hash+".png")
+    txt2image_title(name, dir_title+name_hash+".png",lang)
 
 
 
 
 def file_prepare_long(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
 def file_prepare_long(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
@@ -228,7 +220,6 @@ def file_prepare_long(name, name_hash,text_content,image_urls,multiLang,lang='zh
     txt2image_title(name, dir_title+name_hash+".png",lang)
     txt2image_title(name, dir_title+name_hash+".png",lang)
 
 
 def txt2image(content, save_target,lang='zh'):
 def txt2image(content, save_target,lang='zh'):
-    mulitLang, status = Check_text_content(text_content)
     unicode_text = trim_punctuation(content)
     unicode_text = trim_punctuation(content)
     font = ''
     font = ''
     if lang=='zh':
     if lang=='zh':

+ 3 - 7
api/main.py

@@ -44,6 +44,8 @@ import gSlide
 import aiofiles
 import aiofiles
 import json
 import json
 import util.user
 import util.user
+#https://www.choozmo.com:8887/verify_email?code=16370312713065429 => 
+#https://video.choozmo.com/verify_email.html?code=16370312713065429
 pymysql.install_as_MySQLdb()
 pymysql.install_as_MySQLdb()
 
 
 app = FastAPI()
 app = FastAPI()
@@ -280,13 +282,7 @@ async def register(request: util.models.register_req):
     user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
     user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
     
     
     if user_obj == None:
     if user_obj == None:
-        reg_model = util.models.register_addition()
-        reg_model.username = request.username
-        reg_model.email = request.email
-        reg_model.password =request.password
-        reg_model.left_time = 60
-
-        id = user_register(reg_model)
+        id = user_register(request)
         result = util.user.add_to_basic_role(id)
         result = util.user.add_to_basic_role(id)
         print(result)
         print(result)
         if type(id) is int:
         if type(id) is int: