Spaces:
Running
Running
Try multiple inputs
Browse files
app.py
CHANGED
|
@@ -149,16 +149,34 @@ allow_flagging = "never"
|
|
| 149 |
# # demo.launch()
|
| 150 |
# file.launch()
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
with gr.Blocks() as demo:
|
| 153 |
gr.Markdown(description)
|
| 154 |
with gr.Tab(label="Input"):
|
| 155 |
with gr.Row():
|
| 156 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
input_file = gr.Audio(
|
| 158 |
sources="upload",
|
| 159 |
type="filepath",
|
| 160 |
label="Audio file",
|
| 161 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
# output_selector = gr.Dropdown(
|
| 163 |
# choices=["age", "gender"],
|
| 164 |
# label="Output",
|
|
@@ -177,6 +195,12 @@ with gr.Blocks() as demo:
|
|
| 177 |
|
| 178 |
# output_selector.input(update_output, output_selector, output)
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
demo.launch(debug=True)
|
|
|
|
| 149 |
# # demo.launch()
|
| 150 |
# file.launch()
|
| 151 |
|
| 152 |
+
def toggle_input(choice):
|
| 153 |
+
if choice == "microphone":
|
| 154 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 155 |
+
else:
|
| 156 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
with gr.Blocks() as demo:
|
| 160 |
gr.Markdown(description)
|
| 161 |
with gr.Tab(label="Input"):
|
| 162 |
with gr.Row():
|
| 163 |
with gr.Column():
|
| 164 |
+
input_selection = gr.Radio(
|
| 165 |
+
["microphone", "file"],
|
| 166 |
+
value="file",
|
| 167 |
+
label="How would you like to upload your audio?",
|
| 168 |
+
)
|
| 169 |
input_file = gr.Audio(
|
| 170 |
sources="upload",
|
| 171 |
type="filepath",
|
| 172 |
label="Audio file",
|
| 173 |
)
|
| 174 |
+
input_microphone = gr.Audio(
|
| 175 |
+
sources="microphone",
|
| 176 |
+
type="filepath",
|
| 177 |
+
label="Microphone",
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
# output_selector = gr.Dropdown(
|
| 181 |
# choices=["age", "gender"],
|
| 182 |
# label="Output",
|
|
|
|
| 195 |
|
| 196 |
# output_selector.input(update_output, output_selector, output)
|
| 197 |
|
| 198 |
+
inputs = [input_microphone, input_file]
|
| 199 |
+
outputs = [output_age, output_gender]
|
| 200 |
+
|
| 201 |
+
submit_btn.click(recognize, [input_file], outputs)
|
| 202 |
+
input_selection.change(toggle, input_selection, inputs)
|
| 203 |
+
input_microphone.change(lambda x: x, input_microphone, outputs)
|
| 204 |
+
input_file.change(lambda x: x, input_file, outputs)
|
| 205 |
|
| 206 |
demo.launch(debug=True)
|