scratchyourbrain123 commited on
Commit
ed87501
·
verified ·
1 Parent(s): a66e264

Fix 'str' object has no attribute 'name' error - handle both file objects and string paths

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import subprocess
4
  import sys
5
 
6
  # MuseTalk Gradio Interface
 
7
  def setup_musetalk():
8
  """Clone and setup MuseTalk repository"""
9
  if not os.path.exists('MuseTalk'):
@@ -14,12 +15,16 @@ def setup_musetalk():
14
  def inference(video_file, audio_file, bbox_shift=0):
15
  """Run MuseTalk inference"""
16
  try:
 
 
 
 
17
  # Run inference script
18
  cmd = [
19
  sys.executable,
20
  'scripts/inference/gradio_demo.py',
21
- '--video', video_file.name,
22
- '--audio', audio_file.name,
23
  '--bbox_shift', str(bbox_shift)
24
  ]
25
  result = subprocess.run(cmd, capture_output=True, text=True)
 
4
  import sys
5
 
6
  # MuseTalk Gradio Interface
7
+
8
  def setup_musetalk():
9
  """Clone and setup MuseTalk repository"""
10
  if not os.path.exists('MuseTalk'):
 
15
  def inference(video_file, audio_file, bbox_shift=0):
16
  """Run MuseTalk inference"""
17
  try:
18
+ # Handle both file objects and string paths
19
+ video_path = video_file.name if hasattr(video_file, 'name') else video_file
20
+ audio_path = audio_file.name if hasattr(audio_file, 'name') else audio_file
21
+
22
  # Run inference script
23
  cmd = [
24
  sys.executable,
25
  'scripts/inference/gradio_demo.py',
26
+ '--video', video_path,
27
+ '--audio', audio_path,
28
  '--bbox_shift', str(bbox_shift)
29
  ]
30
  result = subprocess.run(cmd, capture_output=True, text=True)