|
@@ -143,7 +143,7 @@ async def make_anchor_video_v2(req:request):
|
|
|
return {'msg':"無法辨別圖片網址"+imgu}
|
|
|
|
|
|
save_history(req,name_hash)
|
|
|
- x = threading.Thread(target=gen_video, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar)))
|
|
|
+ x = threading.Thread(target=gen_video_queue, args=(name_hash,req.name, req.text_content, req.image_urls,int(req.avatar)))
|
|
|
x.start()
|
|
|
return {"msg":"製作影片需要時間,請您耐心等候,成果會傳送至LINE群組中"}
|
|
|
|
|
@@ -210,9 +210,7 @@ def gen_video(name_hash,name,text_content, image_urls,avatar):
|
|
|
c = rpyc.connect("localhost", 8878)
|
|
|
c._config['sync_request_timeout'] = None
|
|
|
remote_svc = c.root
|
|
|
-
|
|
|
my_answer = remote_svc.call_video(name_hash,name,text_content, image_urls,avatar) # method call
|
|
|
-
|
|
|
shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
|
|
|
os.remove(tmp_video_dir+name_hash+'.mp4')
|
|
|
|
|
@@ -220,20 +218,43 @@ def gen_video_eng(name_hash,name,text_content, image_urls,sub_titles,avatar):
|
|
|
c = rpyc.connect("localhost", 8878)
|
|
|
c._config['sync_request_timeout'] = None
|
|
|
remote_svc = c.root
|
|
|
-
|
|
|
my_answer = remote_svc.call_video_eng(name_hash,name,text_content, image_urls,sub_titles,avatar) # method call
|
|
|
-
|
|
|
shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
|
|
|
os.remove(tmp_video_dir+name_hash+'.mp4')
|
|
|
|
|
|
+def gen_video_queue(name_hash,name,text_content, image_urls,avatar):
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
+ time_stamp = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+ db['video_queue'].insert({'name_hash':name_hash,'name':name,'text_content':text_content,'image_urls':image_urls,'avatar':avatar,'timestamp',time_stamp})
|
|
|
+ while True:
|
|
|
+ if first(db.query('SELECT * FROM video_queue_status'))['status'] == 1:#only one row in this table, which is the id 1 one
|
|
|
+ print('another process running, leave loop')
|
|
|
+ break
|
|
|
+ if first(db.query('SELECT COUNT(1) FROM video_queue'))['COUNT(1)'] == 0:
|
|
|
+ print('all finish, leave loop')
|
|
|
+ break
|
|
|
+ top1 = first(db.query('SELECT * FROM video_queue'))
|
|
|
+ try:
|
|
|
+ db.query('UPDATE video_queue_status SET status = 1;')
|
|
|
+ c = rpyc.connect("localhost", 8868)
|
|
|
+ c._config['sync_request_timeout'] = None
|
|
|
+ remote_svc = c.root
|
|
|
+ my_answer = remote_svc.call_video(top1['name_hash'],top1['name'],top1['text_content'], top1['image_urls'],top1['avatar']) # method call
|
|
|
+ shutil.copy(tmp_video_dir+top1['name_hash']+'.mp4',video_dest+top1['name_hash']+'.mp4')
|
|
|
+ os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
|
|
|
+ except:
|
|
|
+ print('video generation error')
|
|
|
+ notify_group('影片錯誤')
|
|
|
+ db['video_queue'].delete(id=top1['id'])
|
|
|
+ db.query('UPDATE video_queue_status SET status = 0')
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def gen_avatar(name_hash, imgurl):
|
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
db['avatar_queue'].insert({'name_hash':name_hash,'imgurl':imgurl})
|
|
|
while True:
|
|
|
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
-
|
|
|
- statement = 'SELECT * FROM avatar_service_status'#only one row in this table, which id 1 one
|
|
|
+ statement = 'SELECT * FROM avatar_service_status'#only one row in this table, which is the id 1 one
|
|
|
status = -1
|
|
|
for row in db.query(statement):
|
|
|
status = row['status']
|
|
@@ -253,9 +274,6 @@ def gen_avatar(name_hash, imgurl):
|
|
|
db.query(statement)
|
|
|
name_hash = works[0]['name_hash']
|
|
|
imgurl = works[0]['imgurl']
|
|
|
- print(works[0])
|
|
|
- print(name_hash)
|
|
|
- print(imgurl)
|
|
|
c = rpyc.connect("localhost", 8868)
|
|
|
c._config['sync_request_timeout'] = None
|
|
|
remote_svc = c.root
|