Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
more langs, voices option functionality
Browse files- gr_client.py +91 -28
gr_client.py
CHANGED
|
@@ -161,14 +161,14 @@ input_textbox_init = {
|
|
| 161 |
'info': "Also accepts ARPAbet symbols placed within {} brackets.",
|
| 162 |
'lines': 1,
|
| 163 |
'max_lines': 5,
|
| 164 |
-
'autofocus': True
|
| 165 |
}
|
| 166 |
pacing_slider_init = {
|
| 167 |
'value': 1.0,
|
| 168 |
'minimum': 0.5,
|
| 169 |
'maximum': 2.0,
|
| 170 |
'step': 0.1,
|
| 171 |
-
'label': "Duration"
|
| 172 |
}
|
| 173 |
pitch_slider_init = {
|
| 174 |
'minimum': 0,
|
|
@@ -176,7 +176,7 @@ pitch_slider_init = {
|
|
| 176 |
'value': 0.5,
|
| 177 |
'step': 0.05,
|
| 178 |
'label': "Pitch",
|
| 179 |
-
'visible': False
|
| 180 |
}
|
| 181 |
energy_slider_init = {
|
| 182 |
'minimum': 0.1,
|
|
@@ -184,7 +184,7 @@ energy_slider_init = {
|
|
| 184 |
'value': 1.0,
|
| 185 |
'step': 0.05,
|
| 186 |
'label': "Energy",
|
| 187 |
-
'visible': False
|
| 188 |
}
|
| 189 |
anger_slider_init = {
|
| 190 |
'minimum': 0,
|
|
@@ -192,7 +192,7 @@ anger_slider_init = {
|
|
| 192 |
'value': 0,
|
| 193 |
'step': 0.05,
|
| 194 |
'label': "๐ Anger",
|
| 195 |
-
'info': "Tread lightly beyond 0.9"
|
| 196 |
}
|
| 197 |
happy_slider_init = {
|
| 198 |
'minimum': 0,
|
|
@@ -200,7 +200,7 @@ happy_slider_init = {
|
|
| 200 |
'value': 0,
|
| 201 |
'step': 0.05,
|
| 202 |
'label': "๐ Happiness",
|
| 203 |
-
'info': "Tread lightly beyond 0.7"
|
| 204 |
}
|
| 205 |
sad_slider_init = {
|
| 206 |
'minimum': 0,
|
|
@@ -208,7 +208,7 @@ sad_slider_init = {
|
|
| 208 |
'value': 0,
|
| 209 |
'step': 0.05,
|
| 210 |
'label': "๐ญ Sadness",
|
| 211 |
-
'info': "Duration increased when beyond 0.2"
|
| 212 |
}
|
| 213 |
surprise_slider_init = {
|
| 214 |
'minimum': 0,
|
|
@@ -216,7 +216,7 @@ surprise_slider_init = {
|
|
| 216 |
'value': 0,
|
| 217 |
'step': 0.05,
|
| 218 |
'label': "๐ฎ Surprise",
|
| 219 |
-
'info': "Does not play well with Happiness with either being beyond 0.3"
|
| 220 |
}
|
| 221 |
voice_radio_init = {
|
| 222 |
'choices': [*voice_models, (f'+{len(voice_models_more)}', 'more')],
|
|
@@ -226,24 +226,40 @@ voice_radio_init = {
|
|
| 226 |
}
|
| 227 |
deepmoji_checkbox_init = {
|
| 228 |
'label': "Use DeepMoji",
|
| 229 |
-
'info': "Auto adjust emotional values",
|
| 230 |
'value': True,
|
| 231 |
'interactive': True
|
| 232 |
}
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
def set_default_text(lang, deepmoji_checked):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
# DeepMoji only works on English Text
|
| 236 |
checkbox_init = {**deepmoji_checkbox_init}
|
| 237 |
if lang == 'en':
|
| 238 |
checkbox_init['value'] = deepmoji_checked,
|
| 239 |
-
checkbox_init['interactive'] = True
|
| 240 |
else:
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
checkbox_init['
|
|
|
|
|
|
|
| 244 |
|
| 245 |
-
checkbox_enabled = gr.Checkbox(**checkbox_init)
|
| 246 |
-
return default_text[lang],
|
| 247 |
|
| 248 |
# examples component
|
| 249 |
en_examples = [
|
|
@@ -269,9 +285,11 @@ en_examples_dropdown_init = {
|
|
| 269 |
}
|
| 270 |
|
| 271 |
def set_example_as_input(example_text):
|
|
|
|
| 272 |
return example_text
|
| 273 |
|
| 274 |
def toggle_example_dropdown(lang):
|
|
|
|
| 275 |
dropdown_init = {**en_examples_dropdown_init}
|
| 276 |
if lang == 'en':
|
| 277 |
dropdown_init['visible'] = True
|
|
@@ -280,6 +298,15 @@ def toggle_example_dropdown(lang):
|
|
| 280 |
|
| 281 |
return gr.Dropdown(**dropdown_init)
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
def reset_em_sliders(
|
| 284 |
deepmoji_enabled,
|
| 285 |
anger,
|
|
@@ -287,6 +314,7 @@ def reset_em_sliders(
|
|
| 287 |
sad,
|
| 288 |
surprise
|
| 289 |
):
|
|
|
|
| 290 |
if (deepmoji_enabled):
|
| 291 |
return (0, 0, 0, 0)
|
| 292 |
else:
|
|
@@ -304,6 +332,7 @@ def toggle_deepmoji(
|
|
| 304 |
sad,
|
| 305 |
surprise
|
| 306 |
):
|
|
|
|
| 307 |
if checked:
|
| 308 |
return (0, 0, 0, 0)
|
| 309 |
else:
|
|
@@ -325,8 +354,9 @@ language_radio_init = {
|
|
| 325 |
_DESCRIPTION = '''
|
| 326 |
<div>
|
| 327 |
<a style="display:inline-block;" href="https://github.com/DanRuta/xVA-Synth"><img src='https://img.shields.io/github/stars/DanRuta/xVA-Synth?style=social'/></a>
|
|
|
|
| 328 |
<a style="display:inline-block; margin-left: .5em" href="https://discord.gg/nv7c6E2TzV"><img src='https://img.shields.io/discord/794590496202293278.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2'/></a>
|
| 329 |
-
<span style="display: inline-block;margin-left: .5em;vertical-align: top;"><a href="https://huggingface.co/spaces/Pendrokar/xVASynth?duplicate=true" style="" target="_blank"><img style="margin-bottom: 0em;display: inline;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> for a personal CPU-run</span>
|
| 330 |
</div>
|
| 331 |
'''
|
| 332 |
|
|
@@ -397,22 +427,49 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 397 |
]
|
| 398 |
)
|
| 399 |
|
|
|
|
| 400 |
language_radio.change(
|
| 401 |
-
|
| 402 |
-
inputs=
|
| 403 |
-
outputs=
|
|
|
|
|
|
|
| 404 |
)
|
| 405 |
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
)
|
| 411 |
|
|
|
|
| 412 |
language_radio.change(
|
| 413 |
toggle_example_dropdown,
|
| 414 |
inputs=language_radio,
|
| 415 |
-
outputs=en_examples_dropdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
)
|
| 417 |
|
| 418 |
deepmoji_checkbox.change(
|
|
@@ -429,7 +486,9 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 429 |
happy_slider,
|
| 430 |
sad_slider,
|
| 431 |
surprise_slider
|
| 432 |
-
]
|
|
|
|
|
|
|
| 433 |
)
|
| 434 |
|
| 435 |
input_textbox.change(
|
|
@@ -446,7 +505,9 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 446 |
happy_slider,
|
| 447 |
sad_slider,
|
| 448 |
surprise_slider
|
| 449 |
-
]
|
|
|
|
|
|
|
| 450 |
)
|
| 451 |
|
| 452 |
voice_radio.change(
|
|
@@ -463,12 +524,14 @@ with gr.Blocks(css=".arpabet {background-color: gray; border-radius: 5px; font-s
|
|
| 463 |
happy_slider,
|
| 464 |
sad_slider,
|
| 465 |
surprise_slider
|
| 466 |
-
]
|
|
|
|
|
|
|
| 467 |
)
|
| 468 |
|
| 469 |
if __name__ == "__main__":
|
| 470 |
print('running Gradio interface')
|
| 471 |
# gradio_app.launch()
|
| 472 |
-
|
| 473 |
|
| 474 |
demo.launch()
|
|
|
|
| 161 |
'info': "Also accepts ARPAbet symbols placed within {} brackets.",
|
| 162 |
'lines': 1,
|
| 163 |
'max_lines': 5,
|
| 164 |
+
'autofocus': True,
|
| 165 |
}
|
| 166 |
pacing_slider_init = {
|
| 167 |
'value': 1.0,
|
| 168 |
'minimum': 0.5,
|
| 169 |
'maximum': 2.0,
|
| 170 |
'step': 0.1,
|
| 171 |
+
'label': "Duration",
|
| 172 |
}
|
| 173 |
pitch_slider_init = {
|
| 174 |
'minimum': 0,
|
|
|
|
| 176 |
'value': 0.5,
|
| 177 |
'step': 0.05,
|
| 178 |
'label': "Pitch",
|
| 179 |
+
'visible': False,
|
| 180 |
}
|
| 181 |
energy_slider_init = {
|
| 182 |
'minimum': 0.1,
|
|
|
|
| 184 |
'value': 1.0,
|
| 185 |
'step': 0.05,
|
| 186 |
'label': "Energy",
|
| 187 |
+
'visible': False,
|
| 188 |
}
|
| 189 |
anger_slider_init = {
|
| 190 |
'minimum': 0,
|
|
|
|
| 192 |
'value': 0,
|
| 193 |
'step': 0.05,
|
| 194 |
'label': "๐ Anger",
|
| 195 |
+
'info': "Tread lightly beyond 0.9",
|
| 196 |
}
|
| 197 |
happy_slider_init = {
|
| 198 |
'minimum': 0,
|
|
|
|
| 200 |
'value': 0,
|
| 201 |
'step': 0.05,
|
| 202 |
'label': "๐ Happiness",
|
| 203 |
+
'info': "Tread lightly beyond 0.7",
|
| 204 |
}
|
| 205 |
sad_slider_init = {
|
| 206 |
'minimum': 0,
|
|
|
|
| 208 |
'value': 0,
|
| 209 |
'step': 0.05,
|
| 210 |
'label': "๐ญ Sadness",
|
| 211 |
+
'info': "Duration increased when beyond 0.2",
|
| 212 |
}
|
| 213 |
surprise_slider_init = {
|
| 214 |
'minimum': 0,
|
|
|
|
| 216 |
'value': 0,
|
| 217 |
'step': 0.05,
|
| 218 |
'label': "๐ฎ Surprise",
|
| 219 |
+
'info': "Does not play well with Happiness with either being beyond 0.3",
|
| 220 |
}
|
| 221 |
voice_radio_init = {
|
| 222 |
'choices': [*voice_models, (f'+{len(voice_models_more)}', 'more')],
|
|
|
|
| 226 |
}
|
| 227 |
deepmoji_checkbox_init = {
|
| 228 |
'label': "Use DeepMoji",
|
| 229 |
+
'info': "Auto adjust emotional values for English",
|
| 230 |
'value': True,
|
| 231 |
'interactive': True
|
| 232 |
}
|
| 233 |
|
| 234 |
+
def more_lang_options(lang):
|
| 235 |
+
print('more_lang_options')
|
| 236 |
+
if lang != 'more':
|
| 237 |
+
return lang
|
| 238 |
+
|
| 239 |
+
radio_init = {**language_radio_init}
|
| 240 |
+
radio_init['choices'] = [*languages, *languages_more]
|
| 241 |
+
return gr.Radio(**radio_init)
|
| 242 |
+
|
| 243 |
def set_default_text(lang, deepmoji_checked):
|
| 244 |
+
print('set_default_text')
|
| 245 |
+
if lang == 'more':
|
| 246 |
+
return default_text['en'], deepmoji_checked
|
| 247 |
+
# return gr.Textbox(**input_textbox_init), deepmoji_checked
|
| 248 |
+
|
| 249 |
# DeepMoji only works on English Text
|
| 250 |
checkbox_init = {**deepmoji_checkbox_init}
|
| 251 |
if lang == 'en':
|
| 252 |
checkbox_init['value'] = deepmoji_checked,
|
| 253 |
+
# checkbox_init['interactive'] = True
|
| 254 |
else:
|
| 255 |
+
deepmoji_checked = False
|
| 256 |
+
# FIXME: event listener conflict with toggle_deepmoji
|
| 257 |
+
# checkbox_init['info'] = "Works only with English!",
|
| 258 |
+
# checkbox_init['value'] = False,
|
| 259 |
+
# checkbox_init['interactive'] = False
|
| 260 |
|
| 261 |
+
# checkbox_enabled = gr.Checkbox(**checkbox_init)
|
| 262 |
+
return default_text[lang], deepmoji_checked
|
| 263 |
|
| 264 |
# examples component
|
| 265 |
en_examples = [
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
def set_example_as_input(example_text):
|
| 288 |
+
print('set_example_as_input')
|
| 289 |
return example_text
|
| 290 |
|
| 291 |
def toggle_example_dropdown(lang):
|
| 292 |
+
print('toggle_example_dropdown')
|
| 293 |
dropdown_init = {**en_examples_dropdown_init}
|
| 294 |
if lang == 'en':
|
| 295 |
dropdown_init['visible'] = True
|
|
|
|
| 298 |
|
| 299 |
return gr.Dropdown(**dropdown_init)
|
| 300 |
|
| 301 |
+
def more_voice_options(voice):
|
| 302 |
+
print('more_voice_options')
|
| 303 |
+
if voice != 'more':
|
| 304 |
+
return voice
|
| 305 |
+
|
| 306 |
+
radio_init = {**voice_radio_init}
|
| 307 |
+
radio_init['choices'] = [*voice_models, *voice_models_more]
|
| 308 |
+
return gr.Radio(**radio_init)
|
| 309 |
+
|
| 310 |
def reset_em_sliders(
|
| 311 |
deepmoji_enabled,
|
| 312 |
anger,
|
|
|
|
| 314 |
sad,
|
| 315 |
surprise
|
| 316 |
):
|
| 317 |
+
print('reset_em_sliders')
|
| 318 |
if (deepmoji_enabled):
|
| 319 |
return (0, 0, 0, 0)
|
| 320 |
else:
|
|
|
|
| 332 |
sad,
|
| 333 |
surprise
|
| 334 |
):
|
| 335 |
+
print('toggle_deepmoji')
|
| 336 |
if checked:
|
| 337 |
return (0, 0, 0, 0)
|
| 338 |
else:
|
|
|
|
| 354 |
_DESCRIPTION = '''
|
| 355 |
<div>
|
| 356 |
<a style="display:inline-block;" href="https://github.com/DanRuta/xVA-Synth"><img src='https://img.shields.io/github/stars/DanRuta/xVA-Synth?style=social'/></a>
|
| 357 |
+
<a style="display:inline-block;" href="https://www.nexusmods.com/skyrimspecialedition/mods/44184"><img src='https://img.shields.io/badge/Endorsements-3.3k-blue?logo=nexusmods'/></a>
|
| 358 |
<a style="display:inline-block; margin-left: .5em" href="https://discord.gg/nv7c6E2TzV"><img src='https://img.shields.io/discord/794590496202293278.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2'/></a>
|
| 359 |
+
<span style="display: inline-block;margin-left: .5em;vertical-align: top;"><a href="https://huggingface.co/spaces/Pendrokar/xVASynth?duplicate=true" style="" target="_blank"><img style="margin-bottom: 0em;display: inline;" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> for a personal CPU-run one</span>
|
| 360 |
</div>
|
| 361 |
'''
|
| 362 |
|
|
|
|
| 427 |
]
|
| 428 |
)
|
| 429 |
|
| 430 |
+
# more languages option
|
| 431 |
language_radio.change(
|
| 432 |
+
more_lang_options,
|
| 433 |
+
inputs=language_radio,
|
| 434 |
+
outputs=language_radio,
|
| 435 |
+
trigger_mode='once',
|
| 436 |
+
show_progress='hidden',
|
| 437 |
)
|
| 438 |
|
| 439 |
+
# more voices option
|
| 440 |
+
voice_radio.change(
|
| 441 |
+
more_voice_options,
|
| 442 |
+
inputs=voice_radio,
|
| 443 |
+
outputs=voice_radio,
|
| 444 |
+
trigger_mode='once',
|
| 445 |
+
show_progress='hidden',
|
| 446 |
+
queue=False,
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
# set default text
|
| 450 |
+
language_radio.change(
|
| 451 |
+
set_default_text,
|
| 452 |
+
inputs=[language_radio, deepmoji_checkbox],
|
| 453 |
+
outputs=[input_textbox, deepmoji_checkbox],
|
| 454 |
+
show_progress='hidden',
|
| 455 |
+
queue=False,
|
| 456 |
)
|
| 457 |
|
| 458 |
+
# toggle en examples
|
| 459 |
language_radio.change(
|
| 460 |
toggle_example_dropdown,
|
| 461 |
inputs=language_radio,
|
| 462 |
+
outputs=en_examples_dropdown,
|
| 463 |
+
show_progress='hidden',
|
| 464 |
+
queue=False,
|
| 465 |
+
)
|
| 466 |
+
|
| 467 |
+
en_examples_dropdown.change(
|
| 468 |
+
set_example_as_input,
|
| 469 |
+
inputs=[en_examples_dropdown],
|
| 470 |
+
outputs=[input_textbox],
|
| 471 |
+
show_progress='hidden',
|
| 472 |
+
queue=False,
|
| 473 |
)
|
| 474 |
|
| 475 |
deepmoji_checkbox.change(
|
|
|
|
| 486 |
happy_slider,
|
| 487 |
sad_slider,
|
| 488 |
surprise_slider
|
| 489 |
+
],
|
| 490 |
+
show_progress='hidden',
|
| 491 |
+
queue=False,
|
| 492 |
)
|
| 493 |
|
| 494 |
input_textbox.change(
|
|
|
|
| 505 |
happy_slider,
|
| 506 |
sad_slider,
|
| 507 |
surprise_slider
|
| 508 |
+
],
|
| 509 |
+
show_progress='hidden',
|
| 510 |
+
queue=False,
|
| 511 |
)
|
| 512 |
|
| 513 |
voice_radio.change(
|
|
|
|
| 524 |
happy_slider,
|
| 525 |
sad_slider,
|
| 526 |
surprise_slider
|
| 527 |
+
],
|
| 528 |
+
show_progress='hidden',
|
| 529 |
+
queue=False,
|
| 530 |
)
|
| 531 |
|
| 532 |
if __name__ == "__main__":
|
| 533 |
print('running Gradio interface')
|
| 534 |
# gradio_app.launch()
|
| 535 |
+
client = Client("Pendrokar/xVASynth")
|
| 536 |
|
| 537 |
demo.launch()
|