Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
English Examples; uncached
Browse files- gr_client.py +57 -7
gr_client.py
CHANGED
|
@@ -114,7 +114,7 @@ def predict(
|
|
| 114 |
api_name="/predict"
|
| 115 |
)
|
| 116 |
|
| 117 |
-
json_data = json.loads(response)
|
| 118 |
|
| 119 |
arpabet_html = '<h6>ARPAbet & Durations</h6>'
|
| 120 |
arpabet_html += '<table style="margin: 0 var(--size-2)"><tbody><tr>'
|
|
@@ -128,7 +128,6 @@ def predict(
|
|
| 128 |
continue
|
| 129 |
total_dur_length += float(json_data['durations'][symb_i])
|
| 130 |
|
| 131 |
-
print(total_dur_length)
|
| 132 |
for symb_i in range(wpad_len):
|
| 133 |
if (arpabet_symbols[symb_i] == '<PAD>'):
|
| 134 |
continue
|
|
@@ -175,10 +174,6 @@ voice_radio = gr.Radio(
|
|
| 175 |
|
| 176 |
def set_default_text(lang, deepmoji_checked):
|
| 177 |
# DeepMoji only works on English Text
|
| 178 |
-
# checkbox_enabled = True
|
| 179 |
-
# if lang != 'en':
|
| 180 |
-
# checkbox_enabled = False
|
| 181 |
-
|
| 182 |
if lang == 'en':
|
| 183 |
checkbox_enabled = gr.Checkbox(
|
| 184 |
label="Use DeepMoji",
|
|
@@ -196,6 +191,30 @@ def set_default_text(lang, deepmoji_checked):
|
|
| 196 |
|
| 197 |
return default_text[lang], checkbox_enabled # Return the modified textbox (important for Blocks)
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
def reset_em_sliders(
|
| 200 |
deepmoji_enabled,
|
| 201 |
anger,
|
|
@@ -266,7 +285,26 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 266 |
label="Language",
|
| 267 |
info="Will be more monotone and have an English accent. Tested mostly by a native Briton."
|
| 268 |
)
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
with gr.Column(): # Control column
|
| 271 |
voice_radio = gr.Radio(
|
| 272 |
voice_models,
|
|
@@ -330,6 +368,18 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 330 |
outputs=[input_textbox, deepmoji_checkbox]
|
| 331 |
)
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
deepmoji_checkbox.change(
|
| 334 |
toggle_deepmoji,
|
| 335 |
inputs=[
|
|
|
|
| 114 |
api_name="/predict"
|
| 115 |
)
|
| 116 |
|
| 117 |
+
json_data = json.loads(response.replace("'", '"'))
|
| 118 |
|
| 119 |
arpabet_html = '<h6>ARPAbet & Durations</h6>'
|
| 120 |
arpabet_html += '<table style="margin: 0 var(--size-2)"><tbody><tr>'
|
|
|
|
| 128 |
continue
|
| 129 |
total_dur_length += float(json_data['durations'][symb_i])
|
| 130 |
|
|
|
|
| 131 |
for symb_i in range(wpad_len):
|
| 132 |
if (arpabet_symbols[symb_i] == '<PAD>'):
|
| 133 |
continue
|
|
|
|
| 174 |
|
| 175 |
def set_default_text(lang, deepmoji_checked):
|
| 176 |
# DeepMoji only works on English Text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
if lang == 'en':
|
| 178 |
checkbox_enabled = gr.Checkbox(
|
| 179 |
label="Use DeepMoji",
|
|
|
|
| 191 |
|
| 192 |
return default_text[lang], checkbox_enabled # Return the modified textbox (important for Blocks)
|
| 193 |
|
| 194 |
+
def set_example_as_input(example_text):
|
| 195 |
+
return example_text
|
| 196 |
+
|
| 197 |
+
def toggle_example_dropdown(lang):
|
| 198 |
+
if lang == 'en':
|
| 199 |
+
return gr.Dropdown(
|
| 200 |
+
[
|
| 201 |
+
"If there is anything else you need, feel free to ask.",
|
| 202 |
+
"Amazing! Could you do that again?",
|
| 203 |
+
"Why, I would be more than happy to help you!",
|
| 204 |
+
"That was unexpected.",
|
| 205 |
+
"How dare you! . You have no right.",
|
| 206 |
+
"Ahh, well, you see. There is more to it.",
|
| 207 |
+
"I can't believe she is gone.",
|
| 208 |
+
"Stay out of my way!!!",
|
| 209 |
+
],
|
| 210 |
+
label="Example dropdown",
|
| 211 |
+
show_label=False,
|
| 212 |
+
info="English Examples",
|
| 213 |
+
visible=True
|
| 214 |
+
)
|
| 215 |
+
else:
|
| 216 |
+
return gr.Dropdown(visible=False)
|
| 217 |
+
|
| 218 |
def reset_em_sliders(
|
| 219 |
deepmoji_enabled,
|
| 220 |
anger,
|
|
|
|
| 285 |
label="Language",
|
| 286 |
info="Will be more monotone and have an English accent. Tested mostly by a native Briton."
|
| 287 |
)
|
| 288 |
+
|
| 289 |
+
with gr.Row():
|
| 290 |
+
with gr.Column():
|
| 291 |
+
en_examples_dropdown = gr.Dropdown(
|
| 292 |
+
[
|
| 293 |
+
"If there is anything else you need, feel free to ask.",
|
| 294 |
+
"Amazing! Could you do that again?",
|
| 295 |
+
"Why, I would be more than happy to help you!",
|
| 296 |
+
"That was unexpected.",
|
| 297 |
+
"How dare you! . You have no right.",
|
| 298 |
+
"Ahh, well, you see. There is more to it.",
|
| 299 |
+
"I can't believe she is gone.",
|
| 300 |
+
"Stay out of my way!!!",
|
| 301 |
+
],
|
| 302 |
+
label="Example dropdown",
|
| 303 |
+
show_label=False,
|
| 304 |
+
info="English Examples"
|
| 305 |
+
)
|
| 306 |
+
with gr.Column():
|
| 307 |
+
pacing_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Duration")
|
| 308 |
with gr.Column(): # Control column
|
| 309 |
voice_radio = gr.Radio(
|
| 310 |
voice_models,
|
|
|
|
| 368 |
outputs=[input_textbox, deepmoji_checkbox]
|
| 369 |
)
|
| 370 |
|
| 371 |
+
en_examples_dropdown.change(
|
| 372 |
+
set_example_as_input,
|
| 373 |
+
inputs=[en_examples_dropdown],
|
| 374 |
+
outputs=[input_textbox]
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
language_radio.change(
|
| 378 |
+
toggle_example_dropdown,
|
| 379 |
+
inputs=language_radio,
|
| 380 |
+
outputs=en_examples_dropdown
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
deepmoji_checkbox.change(
|
| 384 |
toggle_deepmoji,
|
| 385 |
inputs=[
|