Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,3 +40,23 @@ def generate_audio(prompt, negative_prompt, duration, seed):
|
|
40 |
output_audio = audio_output[0].T.float().cpu().numpy()
|
41 |
sf.write("output.wav", output_audio, pipe.vae.sampling_rate)
|
42 |
return "output.wav"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
output_audio = audio_output[0].T.float().cpu().numpy()
|
41 |
sf.write("output.wav", output_audio, pipe.vae.sampling_rate)
|
42 |
return "output.wav"
|
43 |
+
|
44 |
+
# Gradio UI
|
45 |
+
with gr.Blocks() as demo:
|
46 |
+
gr.Markdown("## 🎧 Stable Audio Open - Interactive Audio Generation 🎼")
|
47 |
+
with gr.Row():
|
48 |
+
prompt_input = gr.Textbox(label="Prompt", value="The sound of a hammer hitting a wooden surface.")
|
49 |
+
negative_input = gr.Textbox(label="Negative Prompt", value="Low quality.")
|
50 |
+
with gr.Row():
|
51 |
+
duration_input = gr.Slider(minimum=1, maximum=10, step=0.5, value=2, label="Duration (seconds)")
|
52 |
+
seed_input = gr.Number(label="Random Seed", value=0)
|
53 |
+
generate_button = gr.Button("Generate Audio")
|
54 |
+
output_audio = gr.Audio(label="Generated Audio", type="filepath")
|
55 |
+
|
56 |
+
generate_button.click(
|
57 |
+
generate_audio,
|
58 |
+
inputs=[prompt_input, negative_input, duration_input, seed_input],
|
59 |
+
outputs=output_audio
|
60 |
+
)
|
61 |
+
|
62 |
+
demo.launch()
|