import subprocess import sys from pathlib import Path # ========= 基础路径 ========= BASE_DIR = Path(__file__).parent.parent A2F_SCRIPT = BASE_DIR / "external" / "Audio2Face-3D-Samples" / "scripts" / "audio2face_3d_microservices_interaction_app" / "a2f_3d.py" AUDIO_FILE = BASE_DIR / "data" / "input" / "audio" / "Mark_joy.wav" CONFIG_FILE = BASE_DIR / "external" / "Audio2Face-3D-Samples" / "scripts" / "audio2face_3d_microservices_interaction_app" / "config" / "config_james.yml" A2F_URL = "192.168.1.39:52000" # ========= 调用命令 ========= cmd = [ sys.executable, # 使用当前 venv 的 python str(A2F_SCRIPT), "run_inference", str(AUDIO_FILE), str(CONFIG_FILE), "--url", A2F_URL ] print("Running Audio2Face-3D inference...") print("Command:", " ".join(cmd)) result = subprocess.run( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True ) print("=== A2F OUTPUT ===") print(result.stdout) if result.returncode != 0: raise RuntimeError("Audio2Face-3D inference failed") print("Inference finished successfully.")