fffiloni commited on
Commit
372395e
β€’
1 Parent(s): cbf2a89

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ caption = gr.Blocks.load(name="spaces/SRDdev/Image-Caption")
4
+ audio_gen = gr.Blocks.load(name="spaces/haoheliu/audioldm-text-to-audio-generation")
5
+
6
+ def infer(image_input):
7
+ cap = caption(image_input, fn_index=0)
8
+ sound = audio_gen(cap, 5, 2.5, 45, 3, fn_index=0)
9
+ return sound
10
+
11
+ with gr.Blocks(css="style.css") as demo:
12
+ with gr.Column(elem_id="col-container"):
13
+
14
+ gr.HTML("""<div style="text-align: center; max-width: 700px; margin: 0 auto;">
15
+ <div
16
+ style="
17
+ display: inline-flex;
18
+ align-items: center;
19
+ gap: 0.8rem;
20
+ font-size: 1.75rem;
21
+ "
22
+ >
23
+ <h1 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
24
+ Image to Sound Effect
25
+ </h1>
26
+ </div>
27
+ <p style="margin-bottom: 10px; font-size: 94%">
28
+ description
29
+ </p>
30
+ </div>""")
31
+
32
+ input_img = gr.Image(type="filepath", elem_id="input-img")
33
+ sound_output = gr.Video(label="Result", elem_id="sound-output")
34
+
35
+ generate = gr.Button("Generate Music from Image")
36
+
37
+ generate.click(infer, inputs=[input_img], outputs=[sound_output], api_name="i2m")
38
+
39
+ demo.queue(max_size=32, concurrency_count=20).launch()