File size: 1,698 Bytes
b17b915 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# =====================================
# File: client_example.py (opcional)
# =====================================
import requests
class VeureuEngineClient:
def __init__(self, base_url: str):
self.base = base_url.rstrip("/")
def process_video(self, video_path: str, **kwargs):
with open(video_path, "rb") as f:
files = {"video_file": (Path(video_path).name, f, "video/mp4")}
data = {"config_path": kwargs.get("config_path", "config_veureu.yaml"),
"out_root": kwargs.get("out_root", "results"),
"db_dir": kwargs.get("db_dir", "chroma_db")}
r = requests.post(f"{self.base}/process_video", files=files, data=data, timeout=3600)
r.raise_for_status()
return r.json()
def load_casting(self, faces_dir: str, voices_dir: str, db_dir: str = "chroma_db", drop_collections: bool = False):
data = {"faces_dir": faces_dir, "voices_dir": voices_dir, "db_dir": db_dir, "drop_collections": str(drop_collections)}
r = requests.post(f"{self.base}/load_casting", data=data, timeout=600)
r.raise_for_status(); return r.json()
def refine_narration(self, dialogues_srt: str, frame_descriptions: list, model_url: str, une_guidelines_path: str):
data = {
"dialogues_srt": dialogues_srt,
"frame_descriptions_json": json.dumps(frame_descriptions, ensure_ascii=False),
"model_url": model_url,
"une_guidelines_path": une_guidelines_path,
}
r = requests.post(f"{self.base}/refine_narration", data=data, timeout=600)
r.raise_for_status(); return r.json() |