| 
														
															@@ -47,6 +47,18 @@ LINE_TOKEN = 'o8dqdVL2k8aiWO4jy3pawZamBu53bbjoSh2u0GJ7F0j' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 router = APIRouter() 
														 | 
														
														 | 
														
															 router = APIRouter() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+def select_voice(lang:str, gender:str='Female'): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if "-" in lang: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        local = lang 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        lang = lang.split("-")[0] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    voices = asyncio.run(VoicesManager.create()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if local: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        voice = voices.find(Gender=gender, Language=lang, Locale=local) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    else: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        voice = voices.find(Gender=gender, Language=lang) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    return voice 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 def gen_prompt(content:str): 
														 | 
														
														 | 
														
															 def gen_prompt(content:str): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     client = OpenAI(base_url="http://192.168.192.84:8080/v1", api_key='choozmo9') 
														 | 
														
														 | 
														
															     client = OpenAI(base_url="http://192.168.192.84:8080/v1", api_key='choozmo9') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -182,6 +194,7 @@ async def wait_finish(model, email, texts, lang): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ws['A1'] = '大標' 
														 | 
														
														 | 
														
															     ws['A1'] = '大標' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ws['B1'] = '字幕' 
														 | 
														
														 | 
														
															     ws['B1'] = '字幕' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ws['C1'] = '素材' 
														 | 
														
														 | 
														
															     ws['C1'] = '素材' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ws['D1'] = '聲音' 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     td = Path(f'/tmp/{datetime.datetime.now().strftime("%Y%m%d%H%M%S-td")}') 
														 | 
														
														 | 
														
															     td = Path(f'/tmp/{datetime.datetime.now().strftime("%Y%m%d%H%M%S-td")}') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     td.mkdir(exist_ok=False) 
														 | 
														
														 | 
														
															     td.mkdir(exist_ok=False) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     dir = td/f'{datetime.datetime.now().strftime("%Y%m%d%H%M%S")}' 
														 | 
														
														 | 
														
															     dir = td/f'{datetime.datetime.now().strftime("%Y%m%d%H%M%S")}' 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -200,6 +213,7 @@ async def wait_finish(model, email, texts, lang): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         print("after", str(img_path)) 
														 | 
														
														 | 
														
															         print("after", str(img_path)) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ws['B'+ str(i+2)] = re.sub(punctuation, r"\\", text) 
														 | 
														
														 | 
														
															         ws['B'+ str(i+2)] = re.sub(punctuation, r"\\", text) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ws['C'+ str(i+2)] = img_path.name 
														 | 
														
														 | 
														
															         ws['C'+ str(i+2)] = img_path.name 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ws['D2'] = select_voice(lang) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     excel_path = Path(dir/'script.xlsx') 
														 | 
														
														 | 
														
															     excel_path = Path(dir/'script.xlsx') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     wb.save(excel_path) 
														 | 
														
														 | 
														
															     wb.save(excel_path) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     output_dir = '/tmp' 
														 | 
														
														 | 
														
															     output_dir = '/tmp' 
														 |