Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 >
|
| 17 |
-
return None, "β Duration too long β max allowed is
|
| 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
|
| 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,
|
| 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)
|