hagenw commited on
Commit
d6e9096
·
1 Parent(s): d1ab157

Try to adjust output type

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -111,7 +111,7 @@ def recognize(file, output_selector):
111
  signal, sampling_rate = audiofile.read(file, duration=duration)
112
  age_gender = process_func(signal, sampling_rate)
113
  if output_selector == "age":
114
- return age_gender["age"]
115
  else:
116
  return {k: v for k, v in age_gender.items() if k != "age"}
117
 
@@ -160,7 +160,14 @@ with gr.Blocks() as demo:
160
  )
161
  submit_btn = gr.Button(value="Submit")
162
  with gr.Column():
163
- output_text = gr.Textbox(label="Output Text")
 
 
 
 
 
 
 
164
 
165
  submit_btn.click(recognize, [audio, output_selector], [output_text])
166
 
 
111
  signal, sampling_rate = audiofile.read(file, duration=duration)
112
  age_gender = process_func(signal, sampling_rate)
113
  if output_selector == "age":
114
+ return f"{round(age_gender['age']} years"
115
  else:
116
  return {k: v for k, v in age_gender.items() if k != "age"}
117
 
 
160
  )
161
  submit_btn = gr.Button(value="Submit")
162
  with gr.Column():
163
+ output = gr.Textbox(label="Age")
164
+
165
+ def update_output(output_selector):
166
+ """Set different output types for different model outputs."""
167
+ output = gr.Label(label="gender")
168
+ return output
169
+
170
+ output_selector.input(update_output, output_selector, output)
171
 
172
  submit_btn.click(recognize, [audio, output_selector], [output_text])
173