Spaces:
Running
Running
Debug
Browse files
app.py
CHANGED
|
@@ -136,7 +136,8 @@ def process_func(x: np.ndarray, sampling_rate: int) -> dict:
|
|
| 136 |
# run through model
|
| 137 |
with torch.no_grad():
|
| 138 |
y = model(y)
|
| 139 |
-
|
|
|
|
| 140 |
# Age-gender model
|
| 141 |
y = torch.hstack([y[1], y[2]])
|
| 142 |
else:
|
|
@@ -181,52 +182,25 @@ def recognize(input_file):
|
|
| 181 |
return process_func(signal, target_rate)
|
| 182 |
|
| 183 |
|
| 184 |
-
outputs = gr.Label()
|
| 185 |
-
title = "audEERING age and gender recognition"
|
| 186 |
description = (
|
| 187 |
-
"
|
| 188 |
-
f"[
|
| 189 |
-
"
|
| 190 |
-
|
| 191 |
-
"is used for expression recognition."
|
| 192 |
)
|
| 193 |
-
allow_flagging = "never"
|
| 194 |
-
|
| 195 |
-
# microphone = gr.Interface(
|
| 196 |
-
# fn=recognize,
|
| 197 |
-
# inputs=gr.Audio(sources="microphone", type="filepath"),
|
| 198 |
-
# outputs=outputs,
|
| 199 |
-
# title=title,
|
| 200 |
-
# description=description,
|
| 201 |
-
# allow_flagging=allow_flagging,
|
| 202 |
-
# )
|
| 203 |
-
|
| 204 |
-
# file = gr.Interface(
|
| 205 |
-
# fn=recognize,
|
| 206 |
-
# inputs=gr.Audio(sources="upload", type="filepath", label="Audio file"),
|
| 207 |
-
# outputs=outputs,
|
| 208 |
-
# title=title,
|
| 209 |
-
# description=description,
|
| 210 |
-
# allow_flagging=allow_flagging,
|
| 211 |
-
# )
|
| 212 |
-
#
|
| 213 |
-
# # demo = gr.TabbedInterface([microphone, file], ["Microphone", "Audio file"])
|
| 214 |
-
# # demo.queue().launch()
|
| 215 |
-
# # demo.launch()
|
| 216 |
-
# file.launch()
|
| 217 |
-
|
| 218 |
|
| 219 |
with gr.Blocks() as demo:
|
| 220 |
gr.Markdown(description)
|
| 221 |
with gr.Tab(label="Speech analysis"):
|
| 222 |
with gr.Row():
|
| 223 |
with gr.Column():
|
| 224 |
-
gr.Markdown(
|
| 225 |
input = gr.Audio(
|
| 226 |
sources=["upload", "microphone"],
|
| 227 |
type="filepath",
|
| 228 |
label="Audio input",
|
| 229 |
)
|
|
|
|
| 230 |
submit_btn = gr.Button(value="Submit")
|
| 231 |
with gr.Column():
|
| 232 |
output_age = gr.Textbox(label="Age")
|
|
|
|
| 136 |
# run through model
|
| 137 |
with torch.no_grad():
|
| 138 |
y = model(y)
|
| 139 |
+
print(f"{y.shape=}")
|
| 140 |
+
if y.shape[0] == 2:
|
| 141 |
# Age-gender model
|
| 142 |
y = torch.hstack([y[1], y[2]])
|
| 143 |
else:
|
|
|
|
| 182 |
return process_func(signal, target_rate)
|
| 183 |
|
| 184 |
|
|
|
|
|
|
|
| 185 |
description = (
|
| 186 |
+
"Recognize "
|
| 187 |
+
f"[age and gender](https://huggingface.co/{age_gender_model_name}) "
|
| 188 |
+
f"and [expression](https://huggingface.co/{expression_model_name}) "
|
| 189 |
+
"of an audio file or microphone recording."
|
|
|
|
| 190 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
with gr.Blocks() as demo:
|
| 193 |
gr.Markdown(description)
|
| 194 |
with gr.Tab(label="Speech analysis"):
|
| 195 |
with gr.Row():
|
| 196 |
with gr.Column():
|
| 197 |
+
gr.Markdown(description)
|
| 198 |
input = gr.Audio(
|
| 199 |
sources=["upload", "microphone"],
|
| 200 |
type="filepath",
|
| 201 |
label="Audio input",
|
| 202 |
)
|
| 203 |
+
gr.Markdown("Only the first second of the audio is processed.")
|
| 204 |
submit_btn = gr.Button(value="Submit")
|
| 205 |
with gr.Column():
|
| 206 |
output_age = gr.Textbox(label="Age")
|