Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,20 +38,20 @@ def load_model(model_path, hps):
|
|
38 |
|
39 |
hps = utils.get_hparams_from_file("configs/vctk_base.json")
|
40 |
|
41 |
-
# Define a dictionary to store the model paths
|
42 |
model_paths = {
|
43 |
-
"
|
44 |
-
"
|
45 |
-
"
|
46 |
-
"
|
47 |
}
|
48 |
|
49 |
# Load the initial model
|
50 |
-
net_g = load_model(model_paths["
|
51 |
|
52 |
-
def tts(text, speaker_id,
|
53 |
global net_g
|
54 |
-
net_g = load_model(model_paths[
|
55 |
|
56 |
if len(text) > 2000:
|
57 |
return "Error: Text is too long", None
|
@@ -67,18 +67,16 @@ def tts(text, speaker_id, model_choice):
|
|
67 |
|
68 |
app = gr.Blocks()
|
69 |
with app:
|
70 |
-
with gr.Tabs():
|
71 |
for tab_name in ["Phonemes_finetuned", "Graphemes_finetuned", "Phonemes", "Graphemes"]:
|
72 |
with gr.TabItem(tab_name):
|
73 |
-
tts_input1 = gr.TextArea(label="Text in Walloon
|
74 |
tts_input2 = gr.Dropdown(label="Speaker", choices=["Male", "Female"], type="index", value="Male")
|
75 |
-
model_choice = gr.Dropdown(label="Model", choices=list(model_paths.keys()), value="Model 1")
|
76 |
tts_submit = gr.Button("Generate", variant="primary")
|
77 |
tts_output1 = gr.Textbox(label="Message")
|
78 |
tts_output2 = gr.Audio(label="Output")
|
79 |
-
tts_submit.click(tts, [tts_input1, tts_input2
|
80 |
|
81 |
app.launch()
|
82 |
-
|
83 |
|
84 |
|
|
|
38 |
|
39 |
hps = utils.get_hparams_from_file("configs/vctk_base.json")
|
40 |
|
41 |
+
# Define a dictionary to store the model paths for each tab
|
42 |
model_paths = {
|
43 |
+
"Phonemes_finetuned": "fr_wa_finetuned_pho/G_125000.pth",
|
44 |
+
"Graphemes_finetuned": "fr_wa_finetuned/G_198000.pth",
|
45 |
+
"Phonemes": "path_to_phonemes_model.pth",
|
46 |
+
"Graphemes": "path_to_graphemes_model.pth"
|
47 |
}
|
48 |
|
49 |
# Load the initial model
|
50 |
+
net_g = load_model(model_paths["Phonemes_finetuned"], hps)
|
51 |
|
52 |
+
def tts(text, speaker_id, tab_name):
|
53 |
global net_g
|
54 |
+
net_g = load_model(model_paths[tab_name], hps)
|
55 |
|
56 |
if len(text) > 2000:
|
57 |
return "Error: Text is too long", None
|
|
|
67 |
|
68 |
app = gr.Blocks()
|
69 |
with app:
|
70 |
+
with gr.Tabs() as tabs:
|
71 |
for tab_name in ["Phonemes_finetuned", "Graphemes_finetuned", "Phonemes", "Graphemes"]:
|
72 |
with gr.TabItem(tab_name):
|
73 |
+
tts_input1 = gr.TextArea(label="Text in Walloon (2000 words limitation)", value="")
|
74 |
tts_input2 = gr.Dropdown(label="Speaker", choices=["Male", "Female"], type="index", value="Male")
|
|
|
75 |
tts_submit = gr.Button("Generate", variant="primary")
|
76 |
tts_output1 = gr.Textbox(label="Message")
|
77 |
tts_output2 = gr.Audio(label="Output")
|
78 |
+
tts_submit.click(tts, [tts_input1, tts_input2], [tts_output1, tts_output2], _js=f"() => '{tab_name}'")
|
79 |
|
80 |
app.launch()
|
|
|
81 |
|
82 |
|