Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -17,23 +17,29 @@ vocoder = load_vocoder()
|
|
17 |
# common usage
|
18 |
v1_base_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
19 |
v1_small_cfg = dict(dim=768, depth=18, heads=12, ff_mult=2, text_dim=512, conv_layers=4)
|
|
|
20 |
alg_vocab_path = str(cached_path("hf://chenxie95/F5-TTS_v1_Small_Algerian/vocab.txt"))
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
}
|
|
|
|
|
37 |
|
38 |
|
39 |
@spaces.GPU
|
@@ -134,14 +140,33 @@ with gr.Blocks() as demo:
|
|
134 |
"""
|
135 |
)
|
136 |
|
137 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
global tts_model_choice
|
139 |
-
tts_model_choice =
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
|
|
|
|
|
|
|
|
|
|
145 |
choose_tts_model.change(
|
146 |
switch_tts_model,
|
147 |
inputs=[choose_tts_model],
|
|
|
17 |
# common usage
|
18 |
v1_base_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
19 |
v1_small_cfg = dict(dim=768, depth=18, heads=12, ff_mult=2, text_dim=512, conv_layers=4)
|
20 |
+
zh_en_vocab_path = str(cached_path("hf://SWivid/F5-TTS/F5TTS_v1_Base/vocab.txt"))
|
21 |
alg_vocab_path = str(cached_path("hf://chenxie95/F5-TTS_v1_Small_Algerian/vocab.txt"))
|
22 |
|
23 |
+
tts_lang_model_collections = {
|
24 |
+
"Mandarin-English": {
|
25 |
+
"v1-base_zh-en": load_model(
|
26 |
+
DiT,
|
27 |
+
v1_base_cfg,
|
28 |
+
str(cached_path("hf://SWivid/F5-TTS/F5TTS_v1_Base/model_1250000.safetensors")),
|
29 |
+
vocab_file=zh_en_vocab_path,
|
30 |
+
),
|
31 |
+
},
|
32 |
+
"Algerian": {
|
33 |
+
"v1-small_alg-64h_400k": load_model(
|
34 |
+
DiT,
|
35 |
+
v1_small_cfg,
|
36 |
+
str(cached_path("hf://chenxie95/F5-TTS_v1_Small_Algerian/64h_model_400000.safetensors")),
|
37 |
+
vocab_file=alg_vocab_path,
|
38 |
+
),
|
39 |
+
},
|
40 |
}
|
41 |
+
tts_lang_choice = next(iter(tts_lang_model_collections)) # first as default
|
42 |
+
tts_model_choice = next(iter(tts_lang_model_collections[tts_lang_choice])) # first as default
|
43 |
|
44 |
|
45 |
@spaces.GPU
|
|
|
140 |
"""
|
141 |
)
|
142 |
|
143 |
+
def switch_tts_lang(new_lang_choice):
|
144 |
+
global tts_lang_choice, tts_model_choice
|
145 |
+
tts_lang_choice = new_lang_choice
|
146 |
+
tts_model_choice = next(iter(tts_lang_model_collections[tts_lang_choice])) # first as default
|
147 |
+
return gr.update(choices=[t for t in tts_lang_model_collections[tts_lang_choice]], value=tts_model_choice)
|
148 |
+
|
149 |
+
def switch_tts_model(new_model_choice):
|
150 |
global tts_model_choice
|
151 |
+
tts_model_choice = new_model_choice
|
152 |
|
153 |
+
with gr.Row():
|
154 |
+
choose_tts_lang = gr.Dropdown(
|
155 |
+
choices=[t for t in tts_lang_model_collections],
|
156 |
+
label="Choose TTS Language",
|
157 |
+
value=tts_lang_choice,
|
158 |
+
)
|
159 |
+
choose_tts_model = gr.Dropdown(
|
160 |
+
choices=[t for t in tts_lang_model_collections[tts_lang_choice]],
|
161 |
+
label="Choose TTS Model",
|
162 |
+
value=tts_model_choice,
|
163 |
+
)
|
164 |
|
165 |
+
choose_tts_lang.change(
|
166 |
+
switch_tts_lang,
|
167 |
+
inputs=[choose_tts_lang],
|
168 |
+
outputs=[choose_tts_model],
|
169 |
+
)
|
170 |
choose_tts_model.change(
|
171 |
switch_tts_model,
|
172 |
inputs=[choose_tts_model],
|