Pipe1213 commited on
Commit
a4a82c5
1 Parent(s): f272b23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
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
- "Model 1": "fr_wa_finetuned_pho/G_125000.pth",
44
- "Model 2": "fr_wa_finetuned/G_198000.pth",
45
- "Model 3": "path_to_model_3_checkpoint.pth",
46
- "Model 4": "path_to_model_4_checkpoint.pth"
47
  }
48
 
49
  # Load the initial model
50
- net_g = load_model(model_paths["Model 1"], hps)
51
 
52
- def tts(text, speaker_id, model_choice):
53
  global net_g
54
- net_g = load_model(model_paths[model_choice], hps)
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 in phonemes IPA (2000 words limitation)", value="")
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, model_choice], [tts_output1, tts_output2])
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