Pendrokar commited on
Commit
21049ce
β€’
1 Parent(s): 2eab215

Examples applied to app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -1
app.py CHANGED
@@ -315,6 +315,30 @@ def set_default_text(lang, deepmoji_checked):
315
 
316
  return default_text[lang], checkbox_enabled # Return the modified textbox (important for Blocks)
317
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  def reset_em_sliders(
319
  deepmoji_enabled,
320
  anger,
@@ -385,7 +409,25 @@ with gr.Blocks(css=".arpabet {display: inline-block; background-color: gray; bor
385
  label="Language",
386
  info="Will be more monotone and have an English accent. Tested mostly by a native Briton."
387
  )
388
- pacing_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Duration")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  with gr.Column(): # Control column
390
  voice_radio = gr.Radio(
391
  voice_models,
@@ -477,6 +519,18 @@ with gr.Blocks(css=".arpabet {display: inline-block; background-color: gray; bor
477
  outputs=[input_textbox, deepmoji_checkbox]
478
  )
479
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  deepmoji_checkbox.change(
481
  toggle_deepmoji,
482
  inputs=[
 
315
 
316
  return default_text[lang], checkbox_enabled # Return the modified textbox (important for Blocks)
317
 
318
+ def set_example_as_input(example_text):
319
+ return example_text
320
+
321
+ def toggle_example_dropdown(lang):
322
+ if lang == 'en':
323
+ return gr.Dropdown(
324
+ [
325
+ "If there is anything else you need, feel free to ask.",
326
+ "Amazing! Could you do that again?",
327
+ "Why, I would be more than happy to help you!",
328
+ "That was unexpected.",
329
+ "How dare you! . You have no right.",
330
+ "Ahh, well, you see. There is more to it.",
331
+ "I can't believe she is gone.",
332
+ "Stay out of my way!!!",
333
+ ],
334
+ label="Example dropdown",
335
+ show_label=False,
336
+ info="English Examples",
337
+ visible=True
338
+ )
339
+ else:
340
+ return gr.Dropdown(visible=False)
341
+
342
  def reset_em_sliders(
343
  deepmoji_enabled,
344
  anger,
 
409
  label="Language",
410
  info="Will be more monotone and have an English accent. Tested mostly by a native Briton."
411
  )
412
+ with gr.Row():
413
+ with gr.Column():
414
+ en_examples_dropdown = gr.Dropdown(
415
+ [
416
+ "If there is anything else you need, feel free to ask.",
417
+ "Amazing! Could you do that again?",
418
+ "Why, I would be more than happy to help you!",
419
+ "That was unexpected.",
420
+ "How dare you! . You have no right.",
421
+ "Ahh, well, you see. There is more to it.",
422
+ "I can't believe she is gone.",
423
+ "Stay out of my way!!!",
424
+ ],
425
+ label="Example dropdown",
426
+ show_label=False,
427
+ info="English Examples"
428
+ )
429
+ with gr.Column():
430
+ pacing_slider = gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Duration")
431
  with gr.Column(): # Control column
432
  voice_radio = gr.Radio(
433
  voice_models,
 
519
  outputs=[input_textbox, deepmoji_checkbox]
520
  )
521
 
522
+ en_examples_dropdown.change(
523
+ set_example_as_input,
524
+ inputs=[en_examples_dropdown],
525
+ outputs=[input_textbox]
526
+ )
527
+
528
+ language_radio.change(
529
+ toggle_example_dropdown,
530
+ inputs=language_radio,
531
+ outputs=en_examples_dropdown
532
+ )
533
+
534
  deepmoji_checkbox.change(
535
  toggle_deepmoji,
536
  inputs=[