fffiloni commited on
Commit
391222d
โ€ข
1 Parent(s): e7592ed

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ img_to_text = gr.Blocks.load(name="spaces/pharma/CLIP-Interrogator")
4
+ text_to_music = gr.Interface.load("spaces/Mubert/Text-to-Music")
5
+
6
+ def get_prompts(uploaded_image):
7
+ prompt = img_to_text(uploaded_image, fn_index=1)[0]
8
+ music_result = get_music(prompt)
9
+ return music_result
10
+
11
+ def get_music(prompt):
12
+ email = "[email protected]"
13
+ duration = 30
14
+ result = text_to_music(email, prompt, duration, loop=False)[0]
15
+ return result
16
+
17
+ with gr.Blocks() as demo:
18
+ with gr.Row():
19
+ with gr.Column():
20
+ input_img = gr.Image(type="filepath")
21
+ generate = gr.Button("Generate Music from Image"
22
+ with gr.Column():
23
+ music_output = gr.Audio(label="Result")
24
+ generate.click(get_prompts, inputs=[input_img], outputs=[music_output]
25
+
26
+ demo.launch()