-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimal_sadtalker.py
More file actions
30 lines (24 loc) · 1 KB
/
minimal_sadtalker.py
File metadata and controls
30 lines (24 loc) · 1 KB
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
import subprocess
import sys
from pathlib import Path
def generate_video(image_path, audio_path, output_path):
"""Minimal SadTalker video generation."""
# Install SadTalker if needed
if not Path("SadTalker").exists():
subprocess.run(["git", "clone", "https://github.com/OpenTalker/SadTalker.git"], check=True)
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "SadTalker/requirements.txt"], check=True)
# Run SadTalker
cmd = [
sys.executable, "inference.py",
"--driven_audio", audio_path,
"--source_image", image_path,
"--result_dir", str(Path(output_path).parent),
"--enhancer", "gfpgan"
]
result = subprocess.run(cmd, cwd="SadTalker", capture_output=True, text=True)
if result.returncode == 0:
# Find generated video
for f in Path(output_path).parent.glob("*.mp4"):
f.rename(output_path)
return str(output_path)
raise Exception(f"Failed: {result.stderr}")