fffiloni commited on
Commit
7718032
1 Parent(s): da2ed3a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ lpmc_client = gr.load("seungheondoh/LP-Music-Caps-demo", src="spaces")
4
+ from gradio_client import Client
5
+
6
+ client = Client("https://ysharma-explore-llamav2-with-tgi.hf.space/")
7
+
8
+
9
+ def infer(audio_file):
10
+
11
+ cap_result = lpmc_client(
12
+ audio_file, # str (filepath or URL to file) in 'audio_path' Audio component
13
+ api_name="predict"
14
+ )
15
+ print(cap_result)
16
+
17
+ result = client.predict(
18
+ cap_result, # str in 'Message' Textbox component
19
+ api_name="chat"
20
+ )
21
+
22
+ print(result)
23
+
24
+ return cap_result, result
25
+
26
+ with gr.Blocks() as demo:
27
+ with gr.Column(elem_id="col-container"):
28
+ audio_input = gr.Audio(type="filepath", source="upload")
29
+ infer_btn = gr.Button("Generate")
30
+ lpmc_cap = gr.Textbox(label="Lp Music Caps caption")
31
+ llama_trans_cap = gr.Textbox(label="Llama translation")
32
+ img_result = gr.Video(label="Result")
33
+
34
+ infer_btn.click(fn=infer, inputs=[audio_input], outputs=[lpmc_cap, llama_trans_cap])
35
+
36
+ demo.queue().launch()