Update app.py
Browse files
app.py
CHANGED
@@ -108,9 +108,23 @@ with gr.Blocks() as demo:
|
|
108 |
""")
|
109 |
|
110 |
with gr.Row():
|
111 |
-
|
112 |
-
gender = gr.Dropdown(choices=
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
generate_btn = gr.Button("Get Audio")
|
116 |
audio_output = gr.Audio(label="Audio", type="filepath", interactive=False)
|
|
|
108 |
""")
|
109 |
|
110 |
with gr.Row():
|
111 |
+
accent = gr.Dropdown(choices=accents, label="Accent", interactive=True)
|
112 |
+
gender = gr.Dropdown(choices=[], label="Gender", interactive=True)
|
113 |
+
age = gr.Dropdown(choices=[], label="Age", interactive=True)
|
114 |
+
|
115 |
+
def update_gender_options(selected_accent):
|
116 |
+
options = sorted(set(entry["gender"] for entry in data if entry["accent"] == selected_accent))
|
117 |
+
return gr.update(choices=options, value=None)
|
118 |
+
|
119 |
+
def update_age_options(selected_accent, selected_gender):
|
120 |
+
options = sorted(set(
|
121 |
+
entry["age"] for entry in data
|
122 |
+
if entry["accent"] == selected_accent and entry["gender"] == selected_gender
|
123 |
+
))
|
124 |
+
return gr.update(choices=options, value=None)
|
125 |
+
|
126 |
+
accent.change(update_gender_options, inputs=[accent], outputs=[gender])
|
127 |
+
gender.change(update_age_options, inputs=[accent, gender], outputs=[age])
|
128 |
|
129 |
generate_btn = gr.Button("Get Audio")
|
130 |
audio_output = gr.Audio(label="Audio", type="filepath", interactive=False)
|