fomext commited on
Commit
31c7598
·
verified ·
1 Parent(s): 95d59d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -56,20 +56,18 @@ def startup():
56
  # -------- API --------
57
  @app.post("/generate")
58
  async def generate(prompt: str, duration: float = 10.0):
59
- """
60
- Generate music/audio from a text prompt using Stable Audio Open
61
- """
62
  load_pipeline()
63
 
 
 
 
64
  with torch.no_grad():
65
  output = pipe(
66
  prompt=prompt,
67
- audio_length_in_s=duration,
68
  guidance_scale=7.5,
69
  num_inference_steps=150,
70
  )
71
 
72
-
73
  audio = output.audios[0]
74
 
75
  filename = f"{uuid.uuid4().hex}.wav"
@@ -82,3 +80,4 @@ async def generate(prompt: str, duration: float = 10.0):
82
  "duration": duration,
83
  "file": filename,
84
  }
 
 
56
  # -------- API --------
57
  @app.post("/generate")
58
  async def generate(prompt: str, duration: float = 10.0):
 
 
 
59
  load_pipeline()
60
 
61
+ # ✅ Stable Audio Open expects duration as a pipeline attribute
62
+ pipe.audio_length_in_s = float(duration)
63
+
64
  with torch.no_grad():
65
  output = pipe(
66
  prompt=prompt,
 
67
  guidance_scale=7.5,
68
  num_inference_steps=150,
69
  )
70
 
 
71
  audio = output.audios[0]
72
 
73
  filename = f"{uuid.uuid4().hex}.wav"
 
80
  "duration": duration,
81
  "file": filename,
82
  }
83
+