浏览代码

add avatar

ming 3 年之前
父节点
当前提交
dc0b4f71e7
共有 3 个文件被更改,包括 17 次插入20 次删除
  1. 4 0
      index2.html
  2. 11 19
      main.py
  3. 2 1
      script_msg.js

+ 4 - 0
index2.html

@@ -62,6 +62,10 @@
     </div>
     <form action="/step_questions/submit" method="post" id="msform">
       <span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; 過去紀錄</span>
+      <select id="avatar" class='avatar'>
+        <option value="6">Angus</option>
+        <option value="7">Peggy</option>
+      </select>
       <!-- fieldsets -->
       <fieldset>
         <h2 class="fs-title">AI ANCHOR</h2>

+ 11 - 19
main.py

@@ -53,25 +53,14 @@ dir_title = 'title/'
 dir_subtitle = 'subtitle/'
 dir_anchor = 'anchor_raw/'
 
-class request(BaseModel):
-    name: str
-    text_content: str
-    image_urls: List[str]
 
-class QQ(BaseModel):
-    n1: str
-    n2: str
 
-
-class request2(BaseModel):
+class request(BaseModel):
     name: str
     text_content: List[str]
     image_urls: List[str]
+    avatar: int
 
-class anchor_request(BaseModel):
-    name: str
-    text_content: str
-    image_urls: List[str]
 
 class ConnectionManager:
     def __init__(self):
@@ -121,7 +110,7 @@ async def progress_page():
 
 
 @app.post("/make_anchor_video_v2")
-async def make_anchor_video_v2(req:request2):
+async def make_anchor_video_v2(req:request):
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
     log_table = db['history_input']
     txt_content_seperate_by_dot = ''
@@ -140,7 +129,7 @@ async def make_anchor_video_v2(req:request2):
     return {"msg":"製作影片需要時間,請您耐心等候  稍後可以在www.choozmo.com:8168/"+req.name+".mp4 中觀看"} 
 
 @app.post("/make_anchor_video_v33")
-async def make_anchor_video_v2(req:request2):
+async def make_anchor_video_v33(req:request2):
     db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
     log_table = db['history_input']
     txt_content_seperate_by_dot = ''
@@ -354,7 +343,7 @@ def txt2image_title(content, save_target):
     draw.text((5,5), text, (17, 41, 167), font)
     canvas.save(save_target, "PNG")
 '''
-def call_achor_video_v2(fileName):
+def call_achor_video_v2(fileName,avatar):
     conn = rpyc.classic.connect("192.168.1.105",18812)
     ros = conn.modules.os 
     rsys = conn.modules.sys 
@@ -374,7 +363,10 @@ def call_achor_video_v2(fileName):
 
     val=random.randint(1000000,9999999)
     ros.chdir('/home/jared/to_video')
-    ros.system('./p6.sh '+str(val)+' &')
+    if avatar ==7:
+        ros.system('./p6.sh '+str(val)+' &')
+    else :
+        ros.system('./p7.sh '+str(val)+' &')
 
     while True:
         print('waiting...')
@@ -580,8 +572,8 @@ def anchor_video_v2(name,text_content, image_urls):
     LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
     LOGO_ED.Open()
     LOGO_ED_clip = video_photo_clip(vid=LOGO_ED,layer=4,position=main_timer,end=LOGO_ED.info.duration+2
-                    ,location_x=0,location_y=-0.02
-                    ,scale_x=0.79,scale_y=0.685)
+                    ,location_x=0,location_y=-0.04
+                    ,scale_x=0.79,scale_y=0.69)
     t.AddClip(LOGO_ED_clip)
     ED_duration = LOGO_ED.info.duration
     LOGO_ED.Close()

+ 2 - 1
script_msg.js

@@ -7,6 +7,7 @@ $(".next").click(function(){
   if( !validate() ){
     return false;
   }
+  avatar = $('.avatar').val();
   name_title = $('.title_new').val();
   txtARR=[];
   imgARR=[];
@@ -22,7 +23,7 @@ $(".next").click(function(){
 		  imgARR.push($(".imgsrc"+step2).val())
 	  }
 	}	
-	dataOBJ = {"name":name_title,"text_content":txtARR,"image_urls":imgARR}
+	dataOBJ = {"name":name_title,"text_content":txtARR,"image_urls":imgARR,"avatar":avatar}
 	objstr = JSON.stringify(dataOBJ);
 	obj2 = JSON.parse(objstr)
 	obj3 = JSON.stringify(obj2)