swayamshetkar commited on
Commit
f098672
Β·
verified Β·
1 Parent(s): 652de6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -13,8 +13,8 @@ model.to(device)
13
  def generate_music(prompt, duration):
14
  if not prompt.strip():
15
  return None, "Please enter a prompt."
16
- if duration > 60:
17
- return None, "❌ Duration too long β€” max allowed is 60 seconds."
18
 
19
  # Prepare inputs
20
  inputs = processor(text=[prompt], return_tensors="pt").to(device)
@@ -37,13 +37,13 @@ def generate_music(prompt, duration):
37
  return tmp.name, f"βœ… Generated {duration}s of audio!"
38
 
39
  with gr.Blocks(title="MusicGen 🎢") as demo:
40
- gr.Markdown("# 🎡 MusicGen β€” Text-to-Music Generator (Extended 60 s Version)")
41
  with gr.Row():
42
  prompt = gr.Textbox(label="🎼 Describe your music", placeholder="e.g. dreamy lo-fi with soft piano")
43
- duration = gr.Slider(4, 60, value=15, step=1, label="Duration (seconds)")
44
  btn = gr.Button("Generate 🎧")
45
  audio_out = gr.Audio(label="🎢 Output", type="filepath")
46
  msg = gr.Textbox(label="Status", interactive=False)
47
  btn.click(generate_music, inputs=[prompt, duration], outputs=[audio_out, msg])
48
 
49
- demo.launch(share=True)
 
13
  def generate_music(prompt, duration):
14
  if not prompt.strip():
15
  return None, "Please enter a prompt."
16
+ if duration > 40:
17
+ return None, "❌ Duration too long β€” max allowed is 40 seconds."
18
 
19
  # Prepare inputs
20
  inputs = processor(text=[prompt], return_tensors="pt").to(device)
 
37
  return tmp.name, f"βœ… Generated {duration}s of audio!"
38
 
39
  with gr.Blocks(title="MusicGen 🎢") as demo:
40
+ gr.Markdown("# 🎡 MusicGen β€” Text-to-Music Generator (Extended 40 s Version)")
41
  with gr.Row():
42
  prompt = gr.Textbox(label="🎼 Describe your music", placeholder="e.g. dreamy lo-fi with soft piano")
43
+ duration = gr.Slider(4, 40, value=15, step=1, label="Duration (seconds)")
44
  btn = gr.Button("Generate 🎧")
45
  audio_out = gr.Audio(label="🎢 Output", type="filepath")
46
  msg = gr.Textbox(label="Status", interactive=False)
47
  btn.click(generate_music, inputs=[prompt, duration], outputs=[audio_out, msg])
48
 
49
+ demo.launch(share=True)