Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ from audiocraft.data.audio import audio_write
|
|
5 |
|
6 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
7 |
|
8 |
-
def infer(prompt):
|
9 |
|
10 |
-
model.set_generation_params(duration=
|
11 |
descriptions = [prompt]
|
12 |
-
wav = model.generate(descriptions) # generates
|
13 |
|
14 |
for idx, one_wav in enumerate(wav):
|
15 |
# Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
|
@@ -17,8 +17,32 @@ def infer(prompt):
|
|
17 |
|
18 |
return "0.wav"
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
model = AudioGen.get_pretrained('facebook/audiogen-medium')
|
7 |
|
8 |
+
def infer(prompt, duration):
|
9 |
|
10 |
+
model.set_generation_params(duration=duration) # generate 5 seconds.
|
11 |
descriptions = [prompt]
|
12 |
+
wav = model.generate(descriptions) # generates n samples (referring to the number n of prompts in descriptions)
|
13 |
|
14 |
for idx, one_wav in enumerate(wav):
|
15 |
# Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
|
|
|
17 |
|
18 |
return "0.wav"
|
19 |
|
20 |
+
css="""
|
21 |
+
#col-container{
|
22 |
+
margin: 0 auto;
|
23 |
+
max-width: 640px;
|
24 |
+
}
|
25 |
+
"""
|
26 |
+
|
27 |
+
with gr.Blocks(css=css) as demo:
|
28 |
+
with gr.Column():
|
29 |
+
gr.HTML("""
|
30 |
+
<h2 style="text-align: center;">
|
31 |
+
AudioGen: Textually-guided audio generation
|
32 |
+
</h2>
|
33 |
+
<p style="text-align: center;">
|
34 |
+
</p>
|
35 |
+
""")
|
36 |
+
|
37 |
+
prompt_in = gr.Textbox(label="audio prompt")
|
38 |
+
duration = gr.Slider(label="Duration", minimum=5, maximum=10, step=5, value=5)
|
39 |
+
submit_btn = gr.Button("Submit")
|
40 |
+
audio_o = gr.Audio(label="AudioGen result")
|
41 |
+
|
42 |
+
submit_btn.click(
|
43 |
+
fn=infer,
|
44 |
+
inputs=[prompt_in, duration],
|
45 |
+
outputs=[audio_o]
|
46 |
+
)
|
47 |
+
|
48 |
+
demo.queue().launch(debug=True)
|