pedropauletti commited on
Commit
5f3740d
1 Parent(s): 995018c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -13
app.py CHANGED
@@ -1,21 +1,51 @@
1
  import gradio as gr
2
 
3
 
4
- def change_textbox(choice):
5
- if choice == "short":
6
- return gr.Textbox(lines=2, visible=True)
7
- elif choice == "long":
8
- return gr.Textbox(lines=8, visible=True, value="Lorem ipsum dolor sit amet")
9
- else:
10
- return gr.Textbox(visible=False)
 
 
 
 
11
 
12
 
13
  with gr.Blocks() as demo:
14
- radio = gr.Radio(
15
- ["short", "long", "none"], label="What kind of essay would you like to write?"
16
- )
17
- text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)
18
- radio.change(fn=change_textbox, inputs=radio, outputs=text)
19
 
 
 
 
20
 
21
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
 
4
+ def to_audioClassification():
5
+ return {
6
+ audio_classification: gr.Row(visible=True),
7
+ realtime_classification: gr.Row(visible=False),
8
+ }
9
+
10
+ def to_realtimeAudioClassification():
11
+ return {
12
+ audio_classification: gr.Row(visible=False),
13
+ realtime_classification: gr.Row(visible=True),
14
+ }
15
 
16
 
17
  with gr.Blocks() as demo:
 
 
 
 
 
18
 
19
+ with gr.Row():
20
+ btn0 = gr.Button("Audio Classification", scale=1, size='lg')
21
+ btn1 = gr.Button("Realtime Audio Classification", scale=1, size='lg')
22
 
23
+ with gr.Row(visible=False) as audio_classification:
24
+ with gr.Column(min_width=700):
25
+ with gr.Accordion("Record an Audio", open=True):
26
+ inputRecord = gr.Audio(label="Audio Input", source="microphone", type="filepath")
27
+ with gr.Accordion("Upload a file", open=False):
28
+ inputUpload = gr.Audio(label="Audio Input", source="upload", type="filepath")
29
+ clearBtn = gr.ClearButton([inputRecord, inputUpload])
30
+ with gr.Column(min_width=700):
31
+ output = gr.Label(label="Audio Classification")
32
+ btn = gr.Button(value="Generate Audio")
33
+ audioOutput = gr.Audio(label="Audio Output", interactive=False)
34
+
35
+
36
+ with gr.Row(visible=False) as realtime_classification:
37
+ with gr.Column(min_width=700):
38
+ input = gr.Audio(label="Audio Input", source="microphone", type="filepath",streaming=True, every=10)
39
+ historyOutput = gr.Textbox(label="History", interactive=False)
40
+ # historyOutput = gr.Label(label="History")
41
+ with gr.Column(min_width=700):
42
+ output = gr.Label(label="Audio Classification")
43
+
44
+
45
+ btn0.click(fn=to_audioClassification, outputs=[audio_classification, realtime_classification, speech_recognition, chatbot_qa])
46
+ btn1.click(fn=to_realtimeAudioClassification, outputs=[audio_classification, realtime_classification, speech_recognition, chatbot_qa])
47
+
48
+
49
+ if __name__ == "__main__":
50
+ demo.queue()
51
+ demo.launch()