MCPcopy
hub / github.com/Zyphra/Zonos / update_ui

Function update_ui

gradio_interface.py:31–82  ·  view source on GitHub ↗

Dynamically show/hide UI elements based on the model's conditioners. We do NOT display 'language_id' or 'ctc_loss' even if they exist in the model.

(model_choice)

Source from the content-addressed store, hash-verified

29
30
31def update_ui(model_choice):
32 """
33 Dynamically show/hide UI elements based on the model's conditioners.
34 We do NOT display 'language_id' or 'ctc_loss' even if they exist in the model.
35 """
36 model = load_model_if_needed(model_choice)
37 cond_names = [c.name for c in model.prefix_conditioner.conditioners]
38 print("Conditioners in this model:", cond_names)
39
40 text_update = gr.update(visible=("espeak" in cond_names))
41 language_update = gr.update(visible=("espeak" in cond_names))
42 speaker_audio_update = gr.update(visible=("speaker" in cond_names))
43 prefix_audio_update = gr.update(visible=True)
44 emotion1_update = gr.update(visible=("emotion" in cond_names))
45 emotion2_update = gr.update(visible=("emotion" in cond_names))
46 emotion3_update = gr.update(visible=("emotion" in cond_names))
47 emotion4_update = gr.update(visible=("emotion" in cond_names))
48 emotion5_update = gr.update(visible=("emotion" in cond_names))
49 emotion6_update = gr.update(visible=("emotion" in cond_names))
50 emotion7_update = gr.update(visible=("emotion" in cond_names))
51 emotion8_update = gr.update(visible=("emotion" in cond_names))
52 vq_single_slider_update = gr.update(visible=("vqscore_8" in cond_names))
53 fmax_slider_update = gr.update(visible=("fmax" in cond_names))
54 pitch_std_slider_update = gr.update(visible=("pitch_std" in cond_names))
55 speaking_rate_slider_update = gr.update(visible=("speaking_rate" in cond_names))
56 dnsmos_slider_update = gr.update(visible=("dnsmos_ovrl" in cond_names))
57 speaker_noised_checkbox_update = gr.update(visible=("speaker_noised" in cond_names))
58 unconditional_keys_update = gr.update(
59 choices=[name for name in cond_names if name not in ("espeak", "language_id")]
60 )
61
62 return (
63 text_update,
64 language_update,
65 speaker_audio_update,
66 prefix_audio_update,
67 emotion1_update,
68 emotion2_update,
69 emotion3_update,
70 emotion4_update,
71 emotion5_update,
72 emotion6_update,
73 emotion7_update,
74 emotion8_update,
75 vq_single_slider_update,
76 fmax_slider_update,
77 pitch_std_slider_update,
78 speaking_rate_slider_update,
79 dnsmos_slider_update,
80 speaker_noised_checkbox_update,
81 unconditional_keys_update,
82 )
83
84
85def generate_audio(

Callers

nothing calls this directly

Calls 1

load_model_if_neededFunction · 0.85

Tested by

no test coverage detected