futurespyhi commited on
Commit
ef411bc
·
1 Parent(s): 9362c34

add debugging for generation failure

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -198,7 +198,7 @@ if project_root not in sys.path:
198
 
199
  from tools.groq_client import client as groq_client
200
  from openai import OpenAI
201
- from tools.generate_lyrics import generate_structured_lyrics, format_lyrics_for_yue, format_lyrics
202
 
203
  # Apply patches after all imports are set up
204
  patch_applied = apply_transformers_patch()
@@ -335,7 +335,16 @@ def generate_music_spaces(lyrics: str, genre: str, mood: str, progress=gr.Progre
335
  # Update command to use relative path since we're in the inference directory
336
  cmd[1] = "infer.py"
337
 
 
 
338
  result = subprocess.run(cmd, capture_output=True, text=True, timeout=1200) # 20 minutes
 
 
 
 
 
 
 
339
  finally:
340
  # Always restore original working directory
341
  os.chdir(original_cwd)
@@ -357,8 +366,12 @@ def generate_music_spaces(lyrics: str, genre: str, mood: str, progress=gr.Progre
357
  else:
358
  return "Music generation completed but no audio file found."
359
  else:
360
- error_msg = result.stderr[-1000:] if result.stderr else "Unknown error"
361
- return f"Music generation failed: {error_msg}"
 
 
 
 
362
 
363
  except subprocess.TimeoutExpired:
364
  return "Music generation timed out after 20 minutes. Please try again."
 
198
 
199
  from tools.groq_client import client as groq_client
200
  from openai import OpenAI
201
+ from tools.generate_lyrics import generate_structured_lyrics, format_lyrics
202
 
203
  # Apply patches after all imports are set up
204
  patch_applied = apply_transformers_patch()
 
335
  # Update command to use relative path since we're in the inference directory
336
  cmd[1] = "infer.py"
337
 
338
+ # Run with real-time output for debugging
339
+ print(f"🚀 Executing command: {' '.join(cmd)}")
340
  result = subprocess.run(cmd, capture_output=True, text=True, timeout=1200) # 20 minutes
341
+
342
+ # Print stdout and stderr for debugging
343
+ if result.stdout:
344
+ print(f"✅ Command output:\n{result.stdout}")
345
+ if result.stderr:
346
+ print(f"⚠️ Command stderr:\n{result.stderr}")
347
+ print(f"📊 Return code: {result.returncode}")
348
  finally:
349
  # Always restore original working directory
350
  os.chdir(original_cwd)
 
366
  else:
367
  return "Music generation completed but no audio file found."
368
  else:
369
+ error_msg = f"Return code: {result.returncode}\n"
370
+ if result.stderr:
371
+ error_msg += f"Error: {result.stderr[-1000:]}\n"
372
+ if result.stdout:
373
+ error_msg += f"Output: {result.stdout[-1000:]}"
374
+ return f"Music generation failed:\n{error_msg}"
375
 
376
  except subprocess.TimeoutExpired:
377
  return "Music generation timed out after 20 minutes. Please try again."